Excel 2K3 Macro - Find and Update

K

kdub-u

Hi All-

Trying to write a simple macro to do the following--Here's my basic
excel spreadsheet. So I have a report that spits this information
out....(could be hundreds of records..all different parts)

A B
Part

AFM
AFM
ANT
BAG
BAG
BAG

What I'd like to be able to do is - for every part it finds - its
update the spreadsheet with a location. So first, it would insert an
additional column - and then update the part location.
For example, If the macro finds the part "AFM" - the Location would be
Y--------If the macro finds the part "ANT" - the location would be
G..etc..etc..

A B C
Part Part Location
AFM Y
AFM Y
ANT G
BAG H
BAG H
BAG H

Thanks for any and all help...I dont know how to program macros.
 
J

JonR

Here's a quick macro that will do what you described in your problems
statement. If you have more part numbers, you simply need to add more Case
statements

Sub Locate()

Dim x As Integer

x = 2

Do While Cells(x, 2).Value <> ""

Select Case Cells(x, 2).Value

Case "AFM"
Cells(x, 3).Value = "Y"

Case "ANT"
Cells(x, 3).Value = "G"

Case "BAG"
Cells(x, 3).Value = "H"

Case Else
Cells(x, 3).Value = "Unknown"

End Select

x = x + 1

Loop

End Sub
 
K

kdub-u

This works like a Champ. I appreciate all your help. You made my life a
littler easier.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top