dynamimic
New Member
- Joined
- Mar 24, 2013
- Messages
- 4
Hi there,
vba virgin up until last week, but I'm trying to teach myself, so please go easy on me.
I'm trying to create an Excel loop which will color rows blue meeting a certain criteria. My subroutine works, however, it always first colors the currently active cell blue before running through the subroutine. I'm assuming its doing this because it's looking for the first command, which is "color selection blue", before it then runs through the loop. So how do I get it to ignore the currently active cell and only color those meeting the criteria?
Nothing too elaborate please... I'm just trying to grasp this particular concept at the moment, and am looking for a simple solution. Here is my subroutine:
Sub ColorCells()
Dim Bazinga As Integer
Bazinga = 2
Do
If Range("A" & Bazinga).Value > 6 And Range("B" & Bazinga).Value = 2 _
Or Range("A" & Bazinga).Value < 3 And Range("B" & Bazinga).Value = 2 _
Then Range("B" & Bazinga).EntireRow.Select
With Selection.Interior
.Color = 15773696
End With
Bazinga = Bazinga + 1
Loop Until Range("A" & Bazinga).Value = ""
End Sub
Thanks for your help.
-dynamimic
vba virgin up until last week, but I'm trying to teach myself, so please go easy on me.
I'm trying to create an Excel loop which will color rows blue meeting a certain criteria. My subroutine works, however, it always first colors the currently active cell blue before running through the subroutine. I'm assuming its doing this because it's looking for the first command, which is "color selection blue", before it then runs through the loop. So how do I get it to ignore the currently active cell and only color those meeting the criteria?
Nothing too elaborate please... I'm just trying to grasp this particular concept at the moment, and am looking for a simple solution. Here is my subroutine:
Sub ColorCells()
Dim Bazinga As Integer
Bazinga = 2
Do
If Range("A" & Bazinga).Value > 6 And Range("B" & Bazinga).Value = 2 _
Or Range("A" & Bazinga).Value < 3 And Range("B" & Bazinga).Value = 2 _
Then Range("B" & Bazinga).EntireRow.Select
With Selection.Interior
.Color = 15773696
End With
Bazinga = Bazinga + 1
Loop Until Range("A" & Bazinga).Value = ""
End Sub
Thanks for your help.
-dynamimic