User Tools

Site Tools


microsoft_excel:macros:add_zeros_to_the_front_of_a_number

This is an old revision of the document!


Microsoft Excel - Macros - 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/add_zeros_to_the_front_of_a_number.1628085231.txt.gz ยท Last modified: 2021/08/04 13:53 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki