![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: London, Tottenham
Posts: 8
|
PLEASE HELP
I am doing a project for college and need some help. I have a sheet that will open on a template but need an auto number to appear in two cells (E3:E4) automatically that are unique each time, preferably sequential. Can some1 help me?????????????? |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: London, UK
Posts: 167
|
a little vba could fix this, but to verify the request, please confirm my understanding,
each time a sheet is added to the workbook, two new numbers are generated sequentially following the highest value of any value in these two cells from any other sheet??? try this in the workbook module... Private Sub Workbook_NewSheet(ByVal Sh As Object) maxval = 0 For sn = 1 To ActiveWorkbook.Sheets.Count If Sheets(sn).Name <> Sh.Name Then If IsNumeric(Sheets(sn).Range("e3")) And Sheets(sn).Range("e3") > maxval Then maxval = Sheets(sn).Range("e3").Value If IsNumeric(Sheets(sn).Range("e4")) And Sheets(sn).Range("e4") > maxval Then maxval = Sheets(sn).Range("e4").Value End If Next Sh.Range("e3") = maxval + 1 Sh.Range("e4") = maxval + 2 End Sub
__________________
<table style="background-color:#0e54be" cellspacing="1" cellpadding="2"><td style="background-color:#ceffff;font-family:arial;color:#072c63;font-size:8pt;">***DALEY** :P**</td></table> |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Location: London, Tottenham
Posts: 8
|
Thanks for your help. I kind of get it but still am a bit confused. Do i replace Sheets with the name of my sheet. Sorry to inconvenience u but is it possible for you to write it again as before but include the sheet name "invoice" in the appropriate places?? THANKS. I AM VERY GRATEFUL!!!
FELLOW LONDONER! |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: London, UK
Posts: 167
|
no, i intended the code for use as-is. it searchs all sheets when you open a new one, and gets two new values sequentially higher than those that appear in the same cells on any other sheet that's already existing in the workbook.
add it to the workbook module of a new book, then keep adding new sheets, you'll see what i mean...
__________________
<table style="background-color:#0e54be" cellspacing="1" cellpadding="2"><td style="background-color:#ceffff;font-family:arial;color:#072c63;font-size:8pt;">***DALEY** :P**</td></table> |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Ahmedabad Gujarat
Posts: 303
|
download the file no 14
http://www.pexcel.com/download.htm here i have given the example of autonumbering.. or you can say invoicnumbering. see if it is helpful to you. file shows how you can use roman nos .. prefix and suffix numbering .. here you can even change start nos it is better if you can see this file. nishith desai http://www.pexcel.com |
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2002
Location: London, Tottenham
Posts: 8
|
Thanks everyone for your help. It is much appreciated!
Love Naz |
|
|
|
|
|
#8 | ||||
|
New Member
Join Date: Apr 2002
Location: London, Tottenham
Posts: 8
|
so far I have tried the following:
Quote:
Quote:
What should happen is that every time a new sheet is opened from the template a different and unique number should appear in e3 and e4. Any more ideas??? (thanks to Nishith desai! but it only adds a new number going down the column each time!) Thanks Naz [ This Message was edited by: naq_uk on 2002-04-15 14:41 ] |
||||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|