ExcelVBA-In a column, change only cells that

Closed
Khennjo - Jan 20, 2010 at 11:23 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Jan 21, 2010 at 05:47 AM
Hello,

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?

Thanks
Related:

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jan 21, 2010 at 05:47 AM
suppose the data
0
1
0
7
2
0
31
10
0
1
in from A2 down. A1 is having column heading.

in B2 copy paste this formula
=IF(LEN(A2)=1,0&A2,A2)
copy B2 down.
0