When value appears adjacent cell acknowledges

[Closed]
Report
-
Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
-
Hello,

I am looking for some VBA code that looks at a column in my worksheet called "Database" and when a value appears in this column, I would like the cell adjacent to it to record a number. For example:

B1 = 001
C1 = Example

When anything appears in Column C:
C2 = Jimmy

I would like B2 to say 002.

When anthing appears in C3:
C3 = Fred

I would like B3 to say 003.

...and so on.


I can do this in an excel worksheet but can't figure out the code for VBA.

Any suggestions would be much appreciated.



1 reply

Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
486
Hi SJJ,

Why use VBA for this?

Select column B, goto cell properties (Ctrl+1), number tab, bottom option and enter 00# in the "Type:" field.

Now enter the following formula in cell B1:
=IF(C1="","",ROW(C1))

Drag formula down as far as you like.

Best regards,
Trowa