![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Microsoft Office support MS Office support forum |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Auto-Numbering in Excel after Row insert
Say I have rows 1-10 (numbered) in column A, I then insert a row, say between 5 & 6 is it possible I can set them to auto re-number automatically?
![]() Thanks.
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: Mar 2008
Posts: 69
OS: XP SP2, Vista
|
Re: Auto-Numbering in Excel after Row insert
Instead of entering the numbers in Column A, you could just use this formula in all of your cells:
=ROW() This will insert the corresponding row number into the cell and will automatically adjust if rows are inserted/deleted. You can add or subtract from that formula as well if your numbers don't match up with the actual row. For example: =ROW()-1 or =ROW()+12 HTH Elkar |
|
|
|
|
|
#3 (permalink) | |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
Quote:
Thanks, I had already tried this... When I insert a new row, I have to manually do something to put the missing number on the newly added row. The above also adds and extra number (e.g., 11) to the bottom of the numbering which I don't need. Other suggestions?
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Mar 2008
Posts: 69
OS: XP SP2, Vista
|
Re: Auto-Numbering in Excel after Row insert
You're going to need a macro for this then. Perhaps something like:
Private Sub Worksheet_Change(ByVal Target As Range)This, will keep the numbers in cells A1 thru A10 as 1 thru 10. It will also prevent the value 10 from moving down to cell A11 if a single row or cell is inserted above. Depending on your needs, you may need to tweak the code a bit. HTH Elkar |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
I'll give it a try...
Thanks.
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
|
|
#6 (permalink) |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
Hi Elkar,
I just had a chance to give it a try. However, I'm a little lost with the macro... Would you mind elaborating (steps) on how to get it to work. I'm not that great with Excel. Thanks.
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Mar 2008
Posts: 69
OS: XP SP2, Vista
|
Re: Auto-Numbering in Excel after Row insert
Open up your workbook.
Hit Alt-F11 to bring up the Visual Basic Editor. On the left side you should see a "Project - VBAProject" window. Find your workbook name there, and expand the tree until you see your individual sheet names listed. Double-click on the worksheet you want to apply this to (ex. "Sheet1" (YourSheetName)) You should now see a larger window open to the right Paste the above code into that window. Close the Visual Basic Editor Try it out HTH Elkar |
|
|
|
|
|
#8 (permalink) | |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
Quote:
Your code works great! I already tested it and works fine... I'll keep playing around and see if my boss likes it. Thanks again.
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
Opps, forgot to ask... how do I start numbering in, let's say on cell A5?
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
|
|
#10 (permalink) |
|
Registered User
Join Date: Mar 2008
Posts: 69
OS: XP SP2, Vista
|
Re: Auto-Numbering in Excel after Row insert
Change the following two lines:
cnt = 5These two numbers are basically your starting row and ending row. Also, you'd likely need to change this line as well: Range("A16").Value = ""The "A16" should be the row following the last cell in your range. And now that I think about it, you could probably rewrite it as: Range("A" & cnt + 1).Value = ""That way it will always be your last row + 1. HTH Elkar |
|
|
|
|
|
#11 (permalink) |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
This starts numbering at #5, I meant to start in cell A5 from #1. Just in case we need to add something on rows 1 & 2 prior to starting numbering.
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor Last edited by texboy; 05-26-2009 at 05:22 PM. |
|
|
|
|
|
#12 (permalink) |
|
Registered User
Join Date: Mar 2008
Posts: 69
OS: XP SP2, Vista
|
Re: Auto-Numbering in Excel after Row insert
Ah yes, didn't think of that. How about we just rewrite the thing to be easier to customize. Try this:
Private Sub Worksheet_Change(ByVal Target As Range)HTH Elkar |
|
|
|
|
|
#13 (permalink) |
|
Registered User
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro
|
Re: Auto-Numbering in Excel after Row insert
It worked!
Thank you much.
__________________
Asus A8N Sli Dx. AMD Opty 165@2400. XP-90 S/Fan. 1 Raptor HD 10Krpm, 250gb Seagate. 2 DVD+/-RW Sata Plextor Drive. 1 XFX 7800GT OCZ 2GB (2 x 1GB)DDR SDRAM Dual Ch.Plat. Logitech THX Z-2300 3PC Spk. Navigator Case 500W Antec Dell 2405FPW 24 in. LCD Monitor |
|
|
|
![]() |
| Thread Tools | |
|
|