Is there a way to declare variables in excel? I have a simple copy and paste macro here.
Dim LastRow As Long
Dim i As Long
Dim RangeOne As Long
Dim RangeTwo As Long
LastRow = Cells(Rows.Count, "BF").End(xlUp).row
For i = 3 To LastRow
If Range("BE" & i).Value <> "" And Range("BD" & i - 1) > 1 And Range("BK" & i - 1) <> "" Then
Range("BG" & i, "BN" & i).Value = Range("BK" & i - 1, "BR" & i - 1).Value
End If
Next i
I defined my range in the loop as RangeOne and RangeTwo so it becomes something like this but it is giving me an error. I know I can name cells out of the editor but is there another way?
Dim LastRow As Long
Dim i As Long
Dim RangeOne As Long
Dim RangeTwo As Long
LastRow = Cells(Rows.Count, "BF").End(xlUp).row
RangeOne = Range("BG" & i, "BN" & i)
RangeTwo = Range("BK" & i - 1, "BR" & i - 1)
For i = 3 To LastRow
If Range("BE" & i).Value <> "" And Range("BD" & i - 1) > 1 And Range("BK" & i - 1) <> "" Then
RangeOne.Value = RangeTwo.Value
End If
Next i
Bookmarks