coding for variable rows

  • Thread starter Thread starter Brad K.
  • Start date Start date
B

Brad K.

I am trying work on sheet that has data pasted to it that always has the same
columns but rows vary each time. I need to enter a value into "B" column and
a formula into "H" & "I" for each row that has data. I have a couple of
macros that do most this, but can't consistently make it work. Any
suggestions?
Thanks,
Brad K.
 
Depends somewhat on what you are doing, eg FormulaR1C1 might work better.
following just for ideas -

Sub test()
Dim nLastRow As Long

' sample data in col-A
For i = 2 To 11
n = n + 10
Cells(i, 1).Value = n
Next

nLastRow = Range("A65536").End(xlUp).Row

Range("B2:B" & nLastRow).Value = 5

Range("H2:H" & nLastRow).Formula = "=A2+B2"
Range("I2:I" & nLastRow).Formula = "=H2 * 10"

End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top