to replace a value in each cell of a column

P

pol

Please let me know how I can write a macro in excel to replace a value in
each cell of the entire column example.

in column B

'1' -> replaced with 'Invoice'
'C' -> replaced with 'Credit note'

I dont not mean in menu -> Find - Replace .

With thanks
Pol
 
J

Jacob Skaria

Sub Macro1()
Columns("A:A").Replace What:="I", Replacement:="Invoice", _
LookAt:=xlWhole, SearchOrder:=xlByRows
Columns("A:A").Replace What:="c", Replacement:="Credit Note", _
LookAt:=xlWhole, SearchOrder:=xlByRows
End Sub

Why dont you try recording one........
 
J

Jacob Skaria

Sub Macro1()
Columns("A:A").Replace What:="I", Replacement:="Invoice", _
LookAt:=xlWhole, SearchOrder:=xlByRows
Columns("A:A").Replace What:="c", Replacement:="Credit Note", _
LookAt:=xlWhole, SearchOrder:=xlByRows
End Sub

Why dont you try recording one........
 
G

Gary''s Student

Sub replacer()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To n
With Cells(i, "B")
If .Value = 1 Then .Value = "Invoice"
If .Value = "C" Then .Value = "Credit note"
End With
Next
End Sub
 
G

Gary''s Student

Sub replacer()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To n
With Cells(i, "B")
If .Value = 1 Then .Value = "Invoice"
If .Value = "C" Then .Value = "Credit note"
End With
Next
End Sub
 
P

pol

Thanks it is working fine. Thansk a lot

Jacob Skaria said:
Sub Macro1()
Columns("A:A").Replace What:="I", Replacement:="Invoice", _
LookAt:=xlWhole, SearchOrder:=xlByRows
Columns("A:A").Replace What:="c", Replacement:="Credit Note", _
LookAt:=xlWhole, SearchOrder:=xlByRows
End Sub

Why dont you try recording one........
 
P

pol

Thanks it is working fine. Thansk a lot

Jacob Skaria said:
Sub Macro1()
Columns("A:A").Replace What:="I", Replacement:="Invoice", _
LookAt:=xlWhole, SearchOrder:=xlByRows
Columns("A:A").Replace What:="c", Replacement:="Credit Note", _
LookAt:=xlWhole, SearchOrder:=xlByRows
End Sub

Why dont you try recording one........
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top