excel - Adding a number to the end of a 4 digit number in a cell, while ignoring every other number -
i trying add number end of 4 digit number in cell, while ignoring every other number.
the code adds zeros , wanted leave out 5 digit numbers.
sub leadingzeros() dim cel range, rg range dim zc double application.screenupdating = false set rg = range("g2") 'first cell converted set rg = range(rg, rg.worksheet.cells(rows.count, rg.column).end(xlup)) 'all data in column rg.numberformat = "@" on error resume next each cel in rg.cells if isnumeric(cel.value) d = val(cel.value) cel.value = format(d, "00000") cel.value = "0" & d end if next on error goto 0 end sub
this should if issue leaving out length of 5.
sub leadingzeros() dim cel range, rg range dim zc double application.screenupdating = false set rg = range("g2") 'first cell converted set rg = range(rg, rg.worksheet.cells(rows.count, rg.column).end(xlup)) 'all data in column rg.numberformat = "@" on error resume next each cel in rg.cells if isnumeric(cel.value) , len(cel.value) <> 5 'this changed less 5, or equals 4, or whatever true criteria d = val(cel.value) cel.value = format(d, "00000") cel.value = "0" & d end if next on error goto 0 end sub
Comments
Post a Comment