LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default macro to add an auto serial number column

Hi,
Need help with VB codes.
I am extracting data from a worksheet form into a data collection worksheet.
The worksheet has pre-existing rows of headers and labels.

I want to auto generate the serial numbers in column A of the data
collection worksheet. I am stuck trying to establish the first serial number
as "1".

Is it possible to code such that:
If the cell above is in column A < "integer" then value in active cell = 1
I get a syntex error with the following:-

With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

If historyWks.Cells(nextRow, "A").Offset(-1, 0) < integer Then
historyWks.Cells(nextRow, "A").Value = 1
Else
historyWks.Cells(nextRow, "A").Value = historyWks.Cells(nextRow,
"A").Offset(-1, 0).Value + 1
End If

'Perhaps there is a better way to do this. Appreciate some help.





 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Serial No Abdul Shakeel Excel Discussion (Misc queries) 1 October 17th 08 12:11 PM
A Macro to find missing serial numbers in a column Khoshravan Excel Discussion (Misc queries) 9 August 6th 06 10:37 AM
Auto number / macro creation Fiona Excel Discussion (Misc queries) 2 March 7th 05 07:05 AM
Auto number w/ different letter-number combos in same column Colleen B Excel Worksheet Functions 2 February 23rd 05 02:41 PM
Set the serial number every 15th column SJ Excel Discussion (Misc queries) 2 February 23rd 05 01:39 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"