Sub macro1()
Dim i As Integer
i = 1
Do
If Cells(i, 1).Value = 5 Then
Cells(i, 1).Value = "apple"
ElseIf Cells(i, 1).Value = 6 Then
Cells(i, 1).Value = "orange"
ElseIf Cells(i, 1).Value = 9 Then
Cells(i, 1).Value = "plum"
ElseIf Cells(i, 1).Value = 12 Then
Cells(i, 1).Value = "banana"
End If
i = i + 1
Loop While Cells(i, 1).Value <> ""
End Sub
Option Explicit
Sub Macro2()
'Written by Trebor76
'Visit my website
Dim rngCell As Range
Application.ScreenUpdating = False
For Each rngCell In Range("A1", Range("A" & Rows.Count).End(xlUp)) 'Starts at row 1. Change to suit.
Select Case rngCell.Value
Case Is = 5
rngCell = "apple"
Case Is = 6
rngCell = "orange"
Case Is = 9
rngCell = "plum"
Case Is = 12
rngCell = "banana"
End Select
Next rngCell
Application.ScreenUpdating = True
MsgBox "Process is complete"
End Sub
Here's my attempt:
Code:Option Explicit Sub Macro2() 'Written by Trebor76 'Visit my website Dim rngCell As Range Application.ScreenUpdating = False For Each rngCell In Range("A1", Range("A" & Rows.Count).End(xlUp)) 'Starts at row 1. Change to suit. Select Case rngCell.Value Case Is = 5 rngCell = "apple" Case Is = 6 rngCell = "orange" Case Is = 9 rngCell = "plum" Case Is = 12 rngCell = "banana" End Select Next rngCell Application.ScreenUpdating = True MsgBox "Process is complete" End Sub
HTH
Robert