I have this code that doesn’t work properly. For every row in column color its giving “Green” results. Could anyone help me find what’s wrong with the code.
Example of the data:
Sub warna()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Variant
Dim vl As Range
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1")
Set rng = ws.Range("B2:B" & ws.Cells(ws.Rows.Count, 1).End(xlUp).Row)
Set vl = ws.Range("B:B")
For Each vl In rng
Select Case vl.Formula
Case "Mango": rng.Offset(0, 1).Formula = "Green"
Case "Apple": rng.Offset(0, 1).Formula = "Pink"
Case "Tangerine": rng.Offset(0, 1).Formula = "Orange"
Case "Cherry": rng.Offset(0, 1).Formula = "Red"
End Select
Next vl
End Sub