Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 310
Default How do I get a number to increase by 1 when opening excel

I have an excel spreadsheet that is used for purchase orders. I would like
to be able to increase the Purchase Order number automaticly by one each time
the spreadsheet is opened.

eg Order 1002 on 18/01/2006 becomes Order 1003 the next time the sheet is
accessed.

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How do I get a number to increase by 1 when opening excel

Hi Micheele,

See JE McGimpsey's sequential numbers page at:

http://www.mcgimpsey.com/excel/udfs/sequentialnums.html


---
Regards,
Norman


"Michelle" wrote in message
...
I have an excel spreadsheet that is used for purchase orders. I would like
to be able to increase the Purchase Order number automaticly by one each
time
the spreadsheet is opened.

eg Order 1002 on 18/01/2006 becomes Order 1003 the next time the sheet is
accessed.

Any suggestions?



  #3   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default How do I get a number to increase by 1 when opening excel

If the link provided by Norman Jones does not help you. Basically, you have
need to add code to your Workbook_open module (located in the ThisWorkbook
portion of the VBA editor) that will run the macro written to update the
purchase order number.

The code for your purchase order number will look at the cell
(Sheet1.Range("A1")) assign a variable to the value of
Sheet1.Range("A1").value. Then increment that value by one. Then do a
Sheet1.Range("A1").value = new value.

Public sub IncrementByOne()
Dim PurOrderNum as long

PurOrderNum = Sheet1.Range("A1").value
PurOrderNum = PurOrderNum + 1
Sheet1.Range("A1").value = PurOrderNum

end sub

This middle code could be shortened to:
Sheet1.Range("A1").value = Sheet1.Range("A1").value + 1

instead of the three lines. I wrote it out so that it might make some
algebraic sense. :)

Under Microsoft Excel Objects of the Project Explorer Window you should be
able to find the ThisWorkbook "worksheet".

If you double click on it you will have code window to enter in the code to
cause the purchase order number to increase on each open of the workbook.

If you paste:

Option Explicit

Private Sub Workbook_Open()
IncrementByOne()
End Sub

and the above IncrementByOne code into this coding area, then you will get
the results that you want. :)


"Michelle" wrote:

I have an excel spreadsheet that is used for purchase orders. I would like
to be able to increase the Purchase Order number automaticly by one each time
the spreadsheet is opened.

eg Order 1002 on 18/01/2006 becomes Order 1003 the next time the sheet is
accessed.

Any suggestions?

Reply
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
how to increase number of characters of file name in excel Manish Excel Discussion (Misc queries) 2 November 10th 08 10:24 AM
Number in cell increase with increase in font size. Value increases with increase in font.[_2_] Excel Discussion (Misc queries) 2 August 9th 07 01:58 PM
How do I increase the number of columns in excel above 256 Roy Excel Discussion (Misc queries) 1 March 29th 07 08:57 PM
The increase number of rows in Excel wise_man Excel Discussion (Misc queries) 12 January 17th 07 02:38 PM
how do i increase the number of columns in excel urbpac Excel Programming 2 September 13th 04 03:08 AM


All times are GMT +1. The time now is 02:50 PM.

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

About Us

"It's about Microsoft Excel"