LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default VLOOKUP Question

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.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
=vlookup question scott Excel Discussion (Misc queries) 0 June 8th 06 06:14 PM
vlookup question Brian Excel Discussion (Misc queries) 1 April 18th 06 03:31 AM
VLOOKUP Question mllestecchino Excel Worksheet Functions 4 April 6th 06 08:53 PM
Vlookup Question carl Excel Worksheet Functions 1 February 21st 06 05:50 PM
vlookup question Greegan Excel Worksheet Functions 3 December 20th 05 04:00 AM


All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"