User Tools

Site Tools


microsoft_excel:macros:padding:add_zeros_to_the_front_of_a_number

Microsoft Excel - Macros - Padding - Add zeros to the front of a number

' Adds 0's to the front of the number.
Dim x
For i = 2 To lastrow_sheet1
  txt = .Range("N" & i).Value
  If Len(txt) < 7 Then
    For x = 1 To (7 - Len(txt))
      txt = "0" & txt
    Next x
  End If
 
  If IsNumeric(txt) Then
    txt = "'" & txt
  End If
 
  .Range("N" & i) = txt
Next i
microsoft_excel/macros/padding/add_zeros_to_the_front_of_a_number.txt · Last modified: 2021/08/04 14:52 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki