B
bundyloco
I'm trying to write a macro that will loop through the cells in colum
to look for a certain string. If it is there, then print a string i
the adjacent cell in colum B. This will loop through until the end o
the range. Coumns A thru P have information in the cells. Here is m
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 rout
one cell to the right
Do
a = Cells(cntr, 1)
b = Cells(cntr, 7)
If a <> "" Or b <> "" Then 'Condition to stop at end o
range
If a = "Product A-1" Or "Greencreek B-0" Or "Greencreek B-0" O
"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 Su
to look for a certain string. If it is there, then print a string i
the adjacent cell in colum B. This will loop through until the end o
the range. Coumns A thru P have information in the cells. Here is m
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 rout
one cell to the right
Do
a = Cells(cntr, 1)
b = Cells(cntr, 7)
If a <> "" Or b <> "" Then 'Condition to stop at end o
range
If a = "Product A-1" Or "Greencreek B-0" Or "Greencreek B-0" O
"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 Su