in the column AR I have to fill in 1 from AR3 to AR13 and 0 from AR14 to the last row. is there any way to automate it in vba?
答案 0 :(得分:0)
Simplest and fastest solution, without a loop
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "AR").End(xlUp).Row
Range("AR3:AR13")=1
Range("AR14:AR" & LastRow )=0
答案 1 :(得分:0)
Dim lRow As Long
Dim ws As Excel.Worksheet
Set ws = Application.ActiveSheet
lRow = 3
Do While lRow <= ws.UsedRange.Rows.count
if lrow <= 13 then
ws.Range("AR" & lrow).Value = 1
Else
ws.Range("AR" & lrow).Value = 0
End if
lRow = lRow + 1
ws.Range("AR" & lRow).Activate
Loop