ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   coding for variable rows (https://www.excelbanter.com/excel-programming/405957-coding-variable-rows.html)

Brad K.

coding for variable rows
 
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.

Peter T

coding for variable rows
 
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

"Brad K." wrote in message
...
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.





All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com