VBA to replace first character in cell on multiple sheets

cruyff73

New Member
Joined
Oct 7, 2016
Messages
32
Hi,

I've got a workbook with multiple sheets. All sheets have identical headers

All cells in column G contain telephone numbers beginning with 0.

Is there any way of cycling through all sheets and changing the first 0 in each cell with +44?

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Assuming that column G is text formatted or custom number formatted you could try this code:

Sub Macro2()
For Each ws In Worksheets
ws.Activate
Columns("G:G").NumberFormat = """+44""#"
Next ws
End Sub
 
Upvote 0
Just noticed that if the cells are stored as text and it works if I convert them to numbers. Is there a way of adding this into the vba to do it all in one hit?
 
Upvote 0
This should work, it is changing the format of the cells to number format as it moves to each sheet. Any cell that is formatted to numbers would loose a leading zero anyway.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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