i want vba code to insert serial number based on cell value

Prasad K

Board Regular
Joined
Aug 4, 2021
Messages
189
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
i want vba code to insert serial number based on cell value like this below

Column A | Serial No Column B | Data if i enter data in column B then insert serial number in column A Automatically & if i delete any data row then the serial number should be update has serial
 

Attachments

  • S-1.JPG
    S-1.JPG
    21.7 KB · Views: 26
  • s-2.jpg
    s-2.jpg
    47.4 KB · Views: 26
  • s-3.JPG
    s-3.JPG
    21.1 KB · Views: 26

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Is your Serial Number really just a row counter, like you have shown, or have you "simplified" the data for the sake of posting it here?
If you have simplified it, can you post a more realistic data sample, so we can see what kind of "pattern" you are using to determine the next value?

Note that if it really is just a row counter, you could use a formula like this (put in cell A2), and copy down column A further than you would ever need and it would show what you want (no VBA required):
Excel Formula:
=IF(B2<>"",ROW()-1,"")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top