VBA Replace number

Ezguy4u

Active Member
Joined
Feb 10, 2010
Messages
366
Office Version
  1. 365
Platform
  1. Windows
I would like to replace the number 5 with the number4. I would like to use VBA. If there are any questions, comments or suggestions, please let me know.

find and replace.xlsx
ABC
1Amount InAmount Out
232563246
389128912
46564
558924892
Data
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
One way...
VBA Code:
Sub Replace5()
 Range("C2:C5").Value = Range("A2:A5").Value
 Range("C2:C5").Replace "5", "4", xlPart
End Sub
 
Upvote 0
Or
Code:
Sub test()
    [c2:c1000] = Application.Substitute([a2:a1000], 5, 4)
End Sub
 
Upvote 0
Solution
I really love this web page. Mark thank you for your solution to my problem. I will be putting your solution into my excel toolbox. Fuji I will be marking your solution as the answer because it has one line of code. I really appreciate seeing the Replace and Substitution function. Thank you both for you time
 
Upvote 0

Forum statistics

Threads
1,224,115
Messages
6,176,467
Members
452,728
Latest member
mihael546

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