I'm trying to add a leading 0 to a numeric column.
The problem is not all numeric columns are recognized as they are.
Sub AddZero()
Dim MyRange As Object
Dim celle As Range
Dim i As Integer
Dim Result As String
Dim StrLen As Integer
Dim cycle As Integer
Set MyRange = Selection
Selection.EntireColumn.Select
Selection.Copy
Selection.Insert
Set celle = Selection
zeri = InputBox("How much 0?")
Length = Val(zeri)
For Each cella In celle
If IsNumeric(cella) Then
StrLen = Len(cella)
cycle = Length + StrLen
For i = 1 To Length
If cycle > StrLen Then
If Not IsEmpty(cella) Then
Result = "0" & cella.Value
cella.Value = Trim(Result)
StrLen = Len(cella)
End If
End If
Next i
End If
Next cella
MyRange.Select
End Sub
I copy and paste the column, and then, I lead an amount of 0 to it.
It works only if I put a '
before cell value even if I remove If IsNumeric(cella)
.