I have the following code in Excel 2010:
Pressing Button 1 highlights row A2:L2 light green. Each subsequent press of Button 2 is supposed to clear the current row's green highlight and then apply the same highlight to the next row down. The problem is I can't figure out how to decrement the row component of the active_row variable.
I know you can't modify the Range.Row() property of a fixed range, but isn't it possible to decrement the row component of my active_row variable by 1? I also read about the resize() function but that doesn't work either because I only want to move the highlighted region down 1 row.
Can I only do this by saving integers corresponding to the range along with the Cells() function and a for each loop?
Code:
Option Explicit
Dim active_row As Range
Private Sub CommandButton1_Click()
Set active_row = Sheets("active").Range("A2:L2")
active_row.Interior.Color = RGB(0, 255, 0)
End Sub
Private Sub CommandButton2_Click()
active_row.Interior.Color = RGB(255, 255, 255)
; code to move active_row range down one row
active_row.Interior.Color = RGB(0, 255, 0)
End Sub
Pressing Button 1 highlights row A2:L2 light green. Each subsequent press of Button 2 is supposed to clear the current row's green highlight and then apply the same highlight to the next row down. The problem is I can't figure out how to decrement the row component of the active_row variable.
I know you can't modify the Range.Row() property of a fixed range, but isn't it possible to decrement the row component of my active_row variable by 1? I also read about the resize() function but that doesn't work either because I only want to move the highlighted region down 1 row.
Can I only do this by saving integers corresponding to the range along with the Cells() function and a for each loop?