Reputation: 141
I am building a spreadsheet and would like a way to automatically increase the cells in column A dependent on whether a user name is entered into Column B. For example:
If A1 = R-0001
and B1 = Sarah
then when a new user enters their name in Column B I would like A2 = R-0002
etc etc
Can anyone help with a macro or alternative that will do this?
Upvotes: 0
Views: 72
Reputation: 50034
This can be done with a cell formula. In A1 enter =If(B1<>"", "R-" & Text(Row(), "0000"), "")
and copy that down however many rows you believe you may have names for.
A quick break down of what this formula does:
Text(Row(), "0000")
bit insures that your Row number that is returned is 4 digits. Cell A1
will produce 0001
where Cell A532 will produce 0532
Upvotes: 1
Reputation: 465
If you want to do this in a formulaic way, you can set the contents of A1 to be
"R-"&TEXT(ROW(),"0000")
which would make the value R-(rownumber), with a fixed with of at least 4. It is probably the most simplistic way of doing this.
Upvotes: 0