bearcub
Well-known Member
- Joined
- May 18, 2005
- Messages
- 731
- Office Version
- 365
- 2013
- 2010
- 2007
- Platform
- Windows
I have the following VBA Code Snippet and I've trying to learn how to use the Cells object.
How would I replace the Activecell object with the Cells object in the Do Loop?
In this instance, the Active cell would be Cells(2,2).
What confuses me is how to replace the activecell object with the cells object in a Do while loop as opposed to a For next loop.
Thank you for your help in advance
How would I replace the Activecell object with the Cells object in the Do Loop?
In this instance, the Active cell would be Cells(2,2).
What confuses me is how to replace the activecell object with the cells object in a Do while loop as opposed to a For next loop.
Code:
Range("B2").Select
'While the activecell isn't blank...
Do While ActiveCell.Value <> ""
'The logical test...
'If the value of the activecell is "Male", AND column E DOES NOT EQUAL "Brown"...
If ActiveCell.Value = "Male" And ActiveCell.Offset(0, 3).Value <> "Brown" Then
'...then write "It's a brown haired MAN!" in column G
ActiveCell.Offset(0, 5).Value = "It's a MAN...but he DOESN't have brown hair!"
End If
'Move down a cell
ActiveCell.Offset(1, 0).Select
Loop
Thank you for your help in advance