PC Review


Reply
Thread Tools Rate Thread

Automatic numbering in excel

 
 
=?Utf-8?B?ZHNoZW1lc2g=?=
Guest
Posts: n/a
 
      24th May 2006
Hello, I am very novice in excel, and have encountered the following problem:
I have a file with a few tables (I use page breaks between 2 tables). The
first column of each table is a serial number column. So I want this column
to automatically start from number 1 (not including the first row, which is a
title row), and keep going, until a page break is encountered (but not when a
regular page ends). How can I do this? I want it of course to handle new
lines as well (every line that I add or remove from a table should change all
serial numbers as needed).

thanks,
--
dshemesh
 
Reply With Quote
 
 
 
 
Ed Ferrero
Guest
Posts: n/a
 
      24th May 2006
Hi dshemesh,

You colud do this with a macro.

Copy the code below (between the ====) to the Visual Basic Editor in Excel.

(In Excel press Alt-F11 to open the VBE, then Insert>Module)

Then select the cell where you want the serial numbers to start, and run the
macro.

'=========================================================================
Sub SetIncrements()
Dim r As Range
Dim i, j As Integer

Set r = Selection

If r.Cells.Count > 1 Then
MsgBox "Select one cell only"
Exit Sub
End If

j = 0

For i = 0 To ActiveSheet.UsedRange.Cells(ActiveSheet.UsedRange.Rows.Count,
1).Row - r.Row
j = j + 1
If r.Offset(i, 0).EntireRow.PageBreak = xlPageBreakManual Then j = 1
r.Offset(i, 0).Value = j
Next i

End Sub
'=========================================================================

Ed Ferrero
http://www.edferrero.com

> Hello, I am very novice in excel, and have encountered the following
> problem:
> I have a file with a few tables (I use page breaks between 2 tables). The
> first column of each table is a serial number column. So I want this
> column
> to automatically start from number 1 (not including the first row, which
> is a
> title row), and keep going, until a page break is encountered (but not
> when a
> regular page ends). How can I do this? I want it of course to handle new
> lines as well (every line that I add or remove from a table should change
> all
> serial numbers as needed).
>
> thanks,
> --
> dshemesh



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic numbering of rows in excel, how to? =?Utf-8?B?TGluZGEgQy4=?= Microsoft Excel Worksheet Functions 9 10th Apr 2009 01:02 PM
Excel/VBA Automatic Numbering manpreet.khera@gmail.com Microsoft Excel New Users 1 8th Feb 2007 10:41 PM
excel automatic numbering =?Utf-8?B?U3BpY2U=?= Microsoft Excel Misc 4 25th Apr 2006 07:04 PM
excel automatic cell numbering don Microsoft Excel Worksheet Functions 1 9th Oct 2004 12:01 AM
Re: automatic numbering in excel Frank Kabel Microsoft Excel Misc 0 31st Aug 2004 10:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 PM.