Reputation: 143
I am trying to make a VBA that gives certain columns a value up until the last row of the first column. This is my code:
Sub Macro8()
'
' Macro8 Macro
'
Dim sh As Worksheet, lastRow As Long
Set sh = ActiveWorkbook.ActiveSheet
lastRow = sh.Cells(sh.Rows.Count, "A").End(xlUp).Row
sh.Range("D" & lastRow).Value = 8.5
sh.Range("E" & lastRow).Value = 6
End Sub
I only seem to get the value on the last row of data, but I want it from the 2nd row to the last row of the first column
Upvotes: 0
Views: 1226
Reputation: 143
all good, worked it out. Pretty basic
Sub Macro8()
'
' Macro8 Macro
'
Dim sh As Worksheet, lastRow As Long
Set sh = ActiveWorkbook.ActiveSheet
lastRow = sh.Cells(sh.Rows.Count, "A").End(xlUp).Row
sh.Range("D2:D" & lastRow).Value = 8.5
sh.Range("E2:E" & lastRow).Value = 6
End Sub
didnt set the range up properly
Upvotes: 1