This seems to be what you want
Dim a As String
Dim b As String
Dim cntr As Integer
'loop through cells to find product and input the corresonding route one
cell to the right
For cntr = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If a = "Product A-1" Or "Greencreek B-0" Or _
"Greencreek B-0" Or "Blackford B-0" Then
ActiveCell.Offset(0, 1).Value = "123.abc"
ElseIf a = "Product B-1" Or "Calistoga A-3" Then
ActiveCell.Offset(0, 1).Value = "456.cde"
ElseIf a = "Product C-1" Then
ActiveCell.Offset(0, 1).Value = "789.fgh"
Else
cntr = cntr + 1
End If
Next i
--
HTH
Bob Phillips
"bundyloco" wrote
in message ...
I'm trying to write a macro that will loop through the cells in colum A
to look for a certain string. If it is there, then print a string in
the adjacent cell in colum B. This will loop through until the end of
the range. Coumns A thru P have information in the cells. Here is my
code. I'm new to vb programming, so any information helps.
Dim a As String
Dim b As String
Dim cntr As Integer
ActiveSheet.Select 'Run on active sheet that is open
cntr = 1
'loop through cells to find product and input the corresonding route
one cell to the right
Do
a = Cells(cntr, 1)
b = Cells(cntr, 7)
If a < "" Or b < "" Then 'Condition to stop at end of
range
If a = "Product A-1" Or "Greencreek B-0" Or "Greencreek B-0" Or
"Blackford B-0" Then
ActiveCell.Offset(0, 1).Value = "123.abc"
ElseIf a = "Product B-1" Or "Calistoga A-3" Then
ActiveCell.Offset(0, 1).Value = "456.cde"
ElseIf a = "Product C-1" Then
ActiveCell.Offset(0, 1).Value = "789.fgh"
Else
cntr = cntr + 1
End If
Else
Exit Do
End If
Loop
End Sub
--
bundyloco
------------------------------------------------------------------------
bundyloco's Profile:
http://www.excelforum.com/member.php...o&userid=23386
View this thread: http://www.excelforum.com/showthread...hreadid=386705