0
Thanks

A few words of thanks would be greatly appreciated.

Excel VBA – In a column, change only cells that



Issue


In Excel VBA, In a column, I want to change only cells that has only one character and add a "0" (zero) prefix.

for example if column C contains the data below,

0 
1 
0 
7 
2 
0 
31 
10 
0 
1


I want to replace those with only one character and add a 0 prefix to look like

00 
01 
00 
07 
02 
00 
31 
10 
00 
01 


Can anyone please help how to code this in Excel VBA?

Solution


In Excel VBA, In a column, I want to change only cells that has only one character and add a "0" (zero) prefix.

for example if column C contains the data below,

0 
1 
0 
7 
2 
0 
31 
10 
0 
1 


I want to replace those with only one character and add a 0 prefix to look like

00 
01 
00 
07 
02 
00 
31 
10 
00 
01 

Can anyone please help how to code this in Excel VBA?

Note


Thanks to venkat1926 for this tip on the forum.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Excel VBA – In a column, change only cells that », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments