I am newbie in Excel Macro. I am trying to do a very simple macro for excel. The Macro will works like IF a specific cell (for example D) contains some categorized string then it will return a specific value in another cell. For an example if any cell of column D contains 'Books', 'Food', 'Fruits' string anywhere of its cell then it will return 01, 02, 03 respectively in Column E. For sure it will very easy task and probably this kind of question asked earlier but as I am newbie please let me know in a brief or any link to get the solution.
I am trying to use this code I found.
Sub Test()
For Counter = 1 To 10000
Set curCell = Worksheets("Sheet1").Cells(Counter, 4)
' 'Books', 'Foods', 'Fruits
If curCell.Value = "Books" Then Worksheets("Sheet1").Cells(Counter, 5) = "01"
elseIf curCell.Value = "Foods" Then Worksheets("Sheet1").Cells(Counter, 5) = "02"
elseIf curCell.Value = "Fruits" Then Worksheets("Sheet1").Cells(Counter, 5) = "03"
End If
Next Counter
End Sub
But It returns an error: Else without IF. What should I do?
Thanks in advance.
Bookmarks