Select cells with value with the help of a code

  • Hello guys

    I am new to the forum. Please update me if I am unaware if my doubts are against the forum rules while trying to solve my query.

    I have these 2 working sheets. Except cell D1 on Sheet Gross and cell A1 in Sheet Extract, the sheet is protected and hidden. I select the date in cell A1 Sheet Extract with a formula, to get the month from Sheet Gross I want to work. When I run the code, the code runs from cells from A1 to AE61. I want the code to select only the cells which have value in the first row and not blank. I need your expert advice to change the code. I want the code to select A1 till the end where the dates end. Different months have different number of days like 28, 29 , 30 and 31.



  • The code you have in the attachment should be changed to

    Code
    Sub Test_2()
    Dim lc As Long
    lc = Sheets("Extract").Rows("1:1").Find("*", , xlValues, , xlByColumns, xlPrevious).Column
    With Sheets("Extract").Cells(2, 1).Resize(60, lc)
    .FormulaR1C1 = "=RANDBETWEEN(10,90*10)*10"
    .Value = .Value
    End With
    End Sub


    Don't know what you're going to do with this.

    Code
    Sub Select_Top_Row()
    Dim lc As Long
    With Sheets("Extract")
    lc = Rows("1:1").Find("*", , xlValues, , xlByColumns, xlPrevious).Column
    .Cells(1, 1).Resize(, lc).Select
    End With
    End Sub
  • It's perect. Thanks jolivanes. I am learning accounts and with the help of different formulas and codes, i am trying to make my work easier and faster.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!