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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Microsoft Support > Microsoft Office support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Microsoft Office support MS Office support forum

Reply
 
LinkBack Thread Tools
Old 05-15-2009, 12:04 PM   #1 (permalink)
Registered User
 
texboy's Avatar
 
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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 05-15-2009, 12:25 PM   #2 (permalink)
Registered User
 
Elkar's Avatar
 
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
Elkar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-15-2009, 01:14 PM   #3 (permalink)
Registered User
 
texboy's Avatar
 
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro


Re: Auto-Numbering in Excel after Row insert

Quote:
Originally Posted by Elkar View Post
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

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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-15-2009, 05:42 PM   #4 (permalink)
Registered User
 
Elkar's Avatar
 
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)

Dim cnt As Integer
cnt = 1

Application.EnableEvents = False
Do While cnt <= 10
Range("A" & cnt).Value = cnt
cnt = cnt + 1
Loop
Range("A11").Value = ""
Application.EnableEvents = True

End Sub
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
Elkar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-18-2009, 09:13 AM   #5 (permalink)
Registered User
 
texboy's Avatar
 
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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-20-2009, 10:13 AM   #6 (permalink)
Registered User
 
texboy's Avatar
 
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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-21-2009, 01:47 PM   #7 (permalink)
Registered User
 
Elkar's Avatar
 
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
Elkar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-26-2009, 12:29 PM   #8 (permalink)
Registered User
 
texboy's Avatar
 
Join Date: Nov 2003
Posts: 136
OS: WinXP MCE Pro


Re: Auto-Numbering in Excel after Row insert

Quote:
Originally Posted by Elkar View Post
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
First, sorry for the long reply... I had a long Holiday weekend.

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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-26-2009, 01:50 PM   #9 (permalink)
Registered User
 
texboy's Avatar
 
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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-26-2009, 04:33 PM   #10 (permalink)
Registered User
 
Elkar's Avatar
 
Join Date: Mar 2008
Posts: 69
OS: XP SP2, Vista


Re: Auto-Numbering in Excel after Row insert

Change the following two lines:
cnt = 5
Do While cnt <=15
These 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
Elkar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-26-2009, 05:11 PM   #11 (permalink)
Registered User
 
texboy's Avatar
 
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.
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-27-2009, 01:53 AM   #12 (permalink)
Registered User
 
Elkar's Avatar
 
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)

Dim StartNum As Integer
Dim FirstCell As Integer
Dim LastCell As Integer

StartNum = 1
FirstCell = 5
LastCell = 15

Application.EnableEvents = False
Do While FirstCell <= LastCell
Range("A" & FirstCell).Value = StartNum
FirstCell = FirstCell + 1
StartNum = StartNum + 1
Loop
Range("A" & LastCell + 1).Value = ""
Application.EnableEvents = True

End Sub
HTH
Elkar
Elkar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-27-2009, 02:53 PM   #13 (permalink)
Registered User
 
texboy's Avatar
 
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
texboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 05:11 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85