#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Formulas

Is there a formula that will add a 1 to a number upon saving a new worksheet.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default Formulas

hi,
possibly.
add a 1 to what number....where?
and what do you mean when you say "Saving a new worksheet"?

Regards
FSt1

"llivey" wrote:

Is there a formula that will add a 1 to a number upon saving a new worksheet.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default Formulas

You need to write a very small macro. Here is the VBA help instructions.
the code must be placed in the Thisworkbook object in VBA. In the Tools Menu
- Macro - visual Basic editor. the left window is the Project Window.
Double click Thisworkbook.

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)

sheets("sheet1").range("A3") = sheets("sheet1").range("A3") + 1
End Sub


VBA Help
---------------------------------------------------------------------------------------
WorkbookBeforeSave Event
See AlsoApplies ToExampleSpecificsOccurs before any open workbook is saved.

Private Sub object_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUi
As Boolean, ByVal Cancel As Boolean)
object An object of type Application declared with events in a class
module. For more information, see Using Events with the Application Object.

Wb The workbook.

SaveAsUi True if the Save As dialog box will be displayed.

Cancel False when the event occurs. If the event procedure sets this
argument to True, the workbook isn't saved when the procedure is finished.

Example
This example prompts the user for a yes or no response before saving any
workbook.

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub



"llivey" wrote:

Is there a formula that will add a 1 to a number upon saving a new worksheet.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Formulas

You cannot save a worksheet, you can only save a workbook.

No, a formula cannot react to a save operation.

You would have to use event code to do what you wish.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
With Sheets("Sheet1").Range("A1")
.Value = .Value + 1
End With
End Sub

Right-click on the Excel logo left of "File" or at left end of Title bar if not
maximized.

Select "View Code" and paste the above into that module.

Alt + q to return to Excel window.

If you are using this method for an invoice or similar, you may want to check
out JE McGimpsey's site on sequential numbering.

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


Gord Dibben MS Excel MVP

On Sat, 5 May 2007 12:46:01 -0700, llivey
wrote:

Is there a formula that will add a 1 to a number upon saving a new worksheet.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,572
Default Formulas

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

--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===

"llivey" wrote in message
...
Is there a formula that will add a 1 to a number upon saving a new
worksheet.




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
CELLS NOT CALC FORMULAS - VALUES STAY SME FORMULAS CORRECT?? HELP Sherberg Excel Worksheet Functions 4 September 11th 07 01:34 AM
automatically copy formulas down columns or copy formulas all the HowlingBlue Excel Worksheet Functions 1 March 16th 07 11:11 PM
Formulas not evaluated, Formulas treated as strings Bob Sullentrup Excel Discussion (Misc queries) 0 November 27th 06 08:01 PM
formulas for changing formulas? creativeops Excel Discussion (Misc queries) 4 January 26th 06 03:07 AM
IF Formulas DBYRON Excel Worksheet Functions 2 October 6th 05 12:21 AM


All times are GMT +1. The time now is 12:06 AM.

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"