G
Guest
Access 2003 - not sure how do write the correct VBA code to accomplish this.
I have a small macro with hard-coded vendor numbers in it that if they are
found, turns the excel line either red or green. But the problem is that
these vendor numbers may change from time to time. Have a worksheet where
these test vendors are stored and want to access this worksheet to used these
instead of relying on the hard-coding.
He is my hard-coding macro:
Sub ColorRich()
x = ActiveCell.Row
Do While Cells(x, 3).Value <> ""
If (Cells(x, 3).Value = 2142) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 2852) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 4761) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 6587) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 2399) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
ElseIf (Cells(x, 3).Value = 9441) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
ElseIf (Cells(x, 3).Value = 10319) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
ElseIf (Cells(x, 3).Value = 12923) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
End If
x = x + 1
Loop
End Sub
And here is a snapshot of my test vendor file:
Column A
Vendor #:
2142
2399
2852
4761
6587
9441
10319
12923
The file I would run this macro against may have anywhere from 1 - x number
of lines so I would like the new macro to run until a blank line is found.
I am very new to VBA and tried to look thru the threads but couldn't put
enought together to figure this out. Thanks in advance for all your help and
suggestions.
I have a small macro with hard-coded vendor numbers in it that if they are
found, turns the excel line either red or green. But the problem is that
these vendor numbers may change from time to time. Have a worksheet where
these test vendors are stored and want to access this worksheet to used these
instead of relying on the hard-coding.
He is my hard-coding macro:
Sub ColorRich()
x = ActiveCell.Row
Do While Cells(x, 3).Value <> ""
If (Cells(x, 3).Value = 2142) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 2852) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 4761) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 6587) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 4
ElseIf (Cells(x, 3).Value = 2399) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
ElseIf (Cells(x, 3).Value = 9441) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
ElseIf (Cells(x, 3).Value = 10319) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
ElseIf (Cells(x, 3).Value = 12923) Then
Cells(x, 3).EntireRow.Interior.ColorIndex = 3
End If
x = x + 1
Loop
End Sub
And here is a snapshot of my test vendor file:
Column A
Vendor #:
2142
2399
2852
4761
6587
9441
10319
12923
The file I would run this macro against may have anywhere from 1 - x number
of lines so I would like the new macro to run until a blank line is found.
I am very new to VBA and tried to look thru the threads but couldn't put
enought together to figure this out. Thanks in advance for all your help and
suggestions.