Question : Format entire coumn for all non null values

I would like to format an entire column without putting data in empty rows.  I can insert the formula "=TEXT(I2,"0000000000")" but how could I replace what is currently in the I column with the new result before with VBA?

Answer : Format entire coumn for all non null values

Well if you want to add leading zeros then use the first code and if you want to add trailing zeros use this code...or for adding zeros in front you can use this...

Saurabh...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Sub filldata()
    Dim lrow As Long

    lrow = Cells(Cells.Rows.Count, "I").End(xlUp).Row
    Dim rng As Range, cell As Range

    Set rng = Range("I1:I" & lrow)

    For Each cell In rng
    
cell.NumberFormat = "@"

        If cell.Value <> "" And Len(cell.Value) < 12 Then cell.Value =  Application.WorksheetFunction.Rept("0", 12 - Len(cell.Value)) & cell.value
    Next cell



End Sub
Random Solutions  
 
programming4us programming4us