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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Ken Cowen

Board Regular
Joined
Jan 18, 2015
Messages
217
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

rafcik

New Member
Joined
Nov 22, 2022
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
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,191,031
Messages
5,984,235
Members
439,879
Latest member
KingGoulash

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
Top