When value appears adjacent cell acknowledges

Closed
SJJ - Feb 12, 2012 at 12:20 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 - Feb 16, 2012 at 09:38 AM
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

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 544
Feb 16, 2012 at 09:38 AM
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
0