I have a macro that someone built from an example worksheet (below), which I need to customize for my actual worksheet. Can someone please tell me what the following command line does and very generally how "ii" gets used in the rest of the macro, so I know what I need to change: For ii = 2 To 4
Worksheet: Excel category example.xlsx
(The macro, copied below, reads the values in columns B, C and D; assigns a category and places it in column E. The actual worksheet has many more rows and columns.)
Thank you!
Lis
Macro:
Public Sub ProcessData()
'add more to categories in a comma delimited lists
Const CAT_CARS As String = "Honda,"
Const CAT_VEG As String = "Celery,Lettuce,"
Const CAT_FRUIT As String = "Apple,Mango,"
Dim Lastrow As Long
Dim i As Long, ii As Long
Application.ScreenUpdating = False
With ActiveSheet
Lastrow = .UsedRange.Rows.Count
For i = 2 To Lastrow
For ii = 2 To 4
If .Cells(i, ii).Value <> "" Then
If InStr(CAT_CARS, .Cells(i, ii).Value & ",") > 0 Then
.Cells(i, "E").Value = "Car"
Exit For
ElseIf InStr(CAT_VEG, .Cells(i, ii).Value & ",") > 0 Then
.Cells(i, "E").Value = "Veggie"
Exit For
ElseIf InStr(CAT_FRUIT, .Cells(i, ii).Value & ",") > 0 Then
.Cells(i, "E").Value = "Fruit"
Exit For
End If
End If
Next ii
Next i
End With
Application.ScreenUpdating = True
End Sub
Bookmarks