Adding leading zeroes to selected alphanumeric cells

  • Thread starter Thread starter TheObstacleIsThePath
  • Start date Start date
T

TheObstacleIsThePath

Can anyone tell me why this only works on the FIRST cell of a
selection rather than ALL selected cells?

Sub fixID()
For Each rng In Selection
rng.NumberFormat = "@"
rng.Value = Right("000000" & rng.Value, 6)
Exit Sub
Next
End Sub

Pardon my ignorance.
 
Can anyone tell me why this only works on the FIRST cell of a
selection rather than ALL selected cells?

Sub fixID()
For Each rng In Selection
rng.NumberFormat = "@"
rng.Value = Right("000000" & rng.Value, 6)
Exit Sub
Next
End Sub

Pardon my ignorance.

nevermind: I read my post and saw the "exit sub" --oops
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top