I'm doing a 'if then else' structure on vba - where i want the if then else function to work on every square - but i can't work out how to make it loop.
so at the moment I want to know if each cell says depreciation and my code is:
ActiveSheet.Cells(2, 1).Select
If ActiveCell = "depreciation" Then
ActiveCell.Interior.Color = vbBlue
Else
MsgBox "error in this cell"
End If
ActiveCell.Offset(1, 0).Select
End Sub
it all works fine except after the next cell is selected the if function doesn't work. Any ideas on how I need to loop this?
Thanks!
so at the moment I want to know if each cell says depreciation and my code is:
ActiveSheet.Cells(2, 1).Select
If ActiveCell = "depreciation" Then
ActiveCell.Interior.Color = vbBlue
Else
MsgBox "error in this cell"
End If
ActiveCell.Offset(1, 0).Select
End Sub
it all works fine except after the next cell is selected the if function doesn't work. Any ideas on how I need to loop this?
Thanks!