VBA to replace values in specific column.

arpirnat

New Member
Joined
Sep 22, 2015
Messages
34
I want the VBA to replace multiple values in a column, and only that column. Currently when I run this it is replacing the values in all columns on the worksheet.

Code:
Columns("H").Replace What:="CHOICE-UEXB IC*", Replacement:="CHOICE UEXB", _
        LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
        False, ReplaceFormat:=False
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
When I run it it only replaces values in column H.
Can you provide the context for that line of code?
There has got to be something else going on as the following works fine for me.


Sub test()


Columns("H").Replace What:="CHOICE-UEXB IC*", Replacement:="CHOICE UEXB"


End Sub




Ken
 
Upvote 0
When I run it it only replaces values in column H.
Can you provide the context for that line of code?
There has got to be something else going on as the following works fine for me.


Sub test()


Columns("H").Replace What:="CHOICE-UEXB IC*", Replacement:="CHOICE UEXB"


End Sub




Ken
Hi Ken,
Correct this piece of code seems to be working fine as well for me, replacing values only in the selected column.

Thanks!
Rafael.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top