Change numbers in column "A"

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
Hi all, kindly require to provide me a VBA code so that to run through col. "A" and should replace the number from left side which "2" into "1". I present below original data and expected result. Thank you all in advance


original data
1205000
1206500
1207700

Expected result
1105000
1106500
1107700
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Code:
Option Explicit


Sub foo()
    Dim i As Long, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 1 To lr
        If InStr(Range("A" & i), 12) = 1 Then
            Range("A" & i) = 11 & Right(Range("A" & i), 5)
        End If
    Next i


End Sub
 
Upvote 0
Thank you mole for advice. I did not think so and is so easy. Thank you so much. have a nice day!
 
Upvote 0
Hi alan, many thanks for code. It works nicely and based to my data. Have a great day!
 
Last edited:
Upvote 0
Hi bosco, your formula works too. Thanks for your time spent for my project. Have a great day!
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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