J
jfcby
Hello,
I wanted to know how to get multiple For Each Next statements to work.
This is what I want For Each Next Statement 1, For Each Next Statement
2 and I'll need to include several but the For Each Next Statement 1 is
the only one that will work the macro will never go to the next one.
My code:
Sub ListBeltSizesPrefix()
'Add prefix to all belt sizes 4L, A, AX, 5L, B, BX
'Add prefix to belt sizes 4L
Dim Cell As Object, Cell2 As Object
For Each Cell In Range("A:A") 'Selection
Cell.Select
If Cell.Value = "" Or Cell.Value = "-" Then
Exit Sub
ElseIf Cell.Value = "4L" Then
Range("A2").Select
Else
Cell.Value = "4L" & Cell.Value
End If
Next Cell
'Add prefix to belt sizes A
For Each Cell2 In Range("B:B") 'Selection
Cell2.Select
If Cell2.Value = "" Or Cell2.Value = "-" Then
Exit Sub
ElseIf Cell2.Value = "A" Then
Range("A2").Select
Else
Cell2.Value = "A" & Cell2.Value
End If
Next Cell2
End Sub
Thank you for your help in advance,
jfcby
I wanted to know how to get multiple For Each Next statements to work.
This is what I want For Each Next Statement 1, For Each Next Statement
2 and I'll need to include several but the For Each Next Statement 1 is
the only one that will work the macro will never go to the next one.
My code:
Sub ListBeltSizesPrefix()
'Add prefix to all belt sizes 4L, A, AX, 5L, B, BX
'Add prefix to belt sizes 4L
Dim Cell As Object, Cell2 As Object
For Each Cell In Range("A:A") 'Selection
Cell.Select
If Cell.Value = "" Or Cell.Value = "-" Then
Exit Sub
ElseIf Cell.Value = "4L" Then
Range("A2").Select
Else
Cell.Value = "4L" & Cell.Value
End If
Next Cell
'Add prefix to belt sizes A
For Each Cell2 In Range("B:B") 'Selection
Cell2.Select
If Cell2.Value = "" Or Cell2.Value = "-" Then
Exit Sub
ElseIf Cell2.Value = "A" Then
Range("A2").Select
Else
Cell2.Value = "A" & Cell2.Value
End If
Next Cell2
End Sub
Thank you for your help in advance,
jfcby