[英]VBA setting values to a column to the last row of another column
I am trying to make a VBA that gives certain columns a value up until the last row of the first column.我正在尝试制作一个 VBA,它为某些列提供一个值,直到第一列的最后一行。 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我似乎只得到最后一行数据的值,但我希望它从第二行到第一列的最后一行
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没有正确设置范围
lastRow = sh.Cells(sh.Rows.Count, "A").End(xlUp).Row + 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.