Link to home
Start Free TrialLog in
Avatar of Alex Campbell
Alex CampbellFlag for United States of America

asked on

Need macro to assign two digit numbers to selected cells in Excel 2016

If I have:
Lucy
Ricky
Fred
Ethel

the macro would change it to
01. Lucy
02. Ricky
03. Fred
04. Ethel
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Maybe this...
Sub ChangeCellContents()
Dim lr As Long, i As Long
Dim rng As Range, cell As Range
lr = ActiveSheet.UsedRange.Rows.Count
Set rng = Range("A1:A" & lr)
i = 1
For Each cell In rng
    cell = Evaluate("TEXT(ROW(A" & i & "),""00. "")") & cell
    i = i + 1
Next cell
End Sub

Open in new window

Avatar of Alex Campbell

ASKER

Great! Liked the simplicity.