# Marcro for looking for certain number and change it to certain word.

#### shawrod

##### Active Member
I am looking for a macro that would look into column A and if it finds 5, change it to apple. If it finds 6, change it to orange. If it finds 9, change it to plum. If it finds 12 change it banana. Can anyone help?

### Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
is the cell value only 5 6 9 or abc5 def6 9efg?

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

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

That did it! Thank you so much!

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

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

Thanks, Robert. I like this one too!

Replies
1
Views
158
Replies
4
Views
246
Replies
6
Views
274
Replies
3
Views
1K
Replies
3
Views
263

1,202,991
Messages
6,052,965
Members
444,622
Latest member
Kriszilla

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back