P
Pedros
Good morning all,
I need a little help with a simple bit of code. (VBA Novice)
Basically what I am trying to do is find the cost centre 46731JA2 in
column B and highlight it and any blank cells underneath it yellow. I
am doing this for about 60 different cost centres. The code below
seems to work fine (although I am open to suggestions as to where I may
have gone the wrong way about it) except the problem is that some of the
cost centres do no appear in every export.
The Problem is that if the cost centre does not appear in the export
the Macro runs to the bottom of the page then causes an error.
How do I make it stop and move on to searching for the next cost centre
if this occurs?
Thanks in advance
THE CODE:
Dim Found46731JA2 As String
Range("B1").Select
Found46731JA2 = ActiveCell.Value
Do Until Found46731JA2 = "46731JA2"
Found46731JA2 = ActiveCell.Offset(1, 0).Value
ActiveCell.Offset(1, 0).Activate
Loop
Selection.Interior.ColorIndex = 6
ActiveCell.Offset(1, 0).Activate
Do While ActiveCell = ""
Selection.Interior.ColorIndex = 6
ActiveCell.Offset(1, 0).Activate
Loop
I need a little help with a simple bit of code. (VBA Novice)
Basically what I am trying to do is find the cost centre 46731JA2 in
column B and highlight it and any blank cells underneath it yellow. I
am doing this for about 60 different cost centres. The code below
seems to work fine (although I am open to suggestions as to where I may
have gone the wrong way about it) except the problem is that some of the
cost centres do no appear in every export.
The Problem is that if the cost centre does not appear in the export
the Macro runs to the bottom of the page then causes an error.
How do I make it stop and move on to searching for the next cost centre
if this occurs?
Thanks in advance
THE CODE:
Dim Found46731JA2 As String
Range("B1").Select
Found46731JA2 = ActiveCell.Value
Do Until Found46731JA2 = "46731JA2"
Found46731JA2 = ActiveCell.Offset(1, 0).Value
ActiveCell.Offset(1, 0).Activate
Loop
Selection.Interior.ColorIndex = 6
ActiveCell.Offset(1, 0).Activate
Do While ActiveCell = ""
Selection.Interior.ColorIndex = 6
ActiveCell.Offset(1, 0).Activate
Loop