Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default macro to a number + 1 to a cell

i have a quote sheet and in h12 there is the quote number. i want change the quote number just before i close and save.when i open it again the next number will appear and i don't have to try to remember that quote number as in 2032 i hit a micro and the number goes to 2033 and saves

please help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default macro to a number + 1 to a cell

Hi Alan
A small macro would do it.
Change the name of the sheet ("Quote") to yours
In the VBA editor under Project select "This workbook" and place the macro on
that sheet..
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Quote").Range("H12").Value = Sheets("Quote").Range("H12").Value + 1
ThisWorkbook.Save
End Sub
HTH
Cimjet


"Alan R" wrote in message
...
i have a quote sheet and in h12 there is the quote number. i want change the
quote number just before i close and save.when i open it again the next number
will appear and i don't have to try to remember that quote number as in 2032 i
hit a micro and the number goes to 2033 and saves

please help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default macro to a number + 1 to a cell

or is there a way to have the value change on close
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default macro to a number + 1 to a cell

"Alan R" wrote in message
...
or is there a way to have the value change on close



that question was answered, I believe, in a post by Gord earlier.

The macro needs to be posted into the "This Workbook" module not the
worksheet module ... so when you right click on the sheet tab and "view
Code", you need to then select the "this workbook" module before pasting
the sample code.

I believe there is a project manager pane open on the left side of the
screen by default that will show the different modules. If it is not
showing, check the options under the View menu.

--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default macro to a number + 1 to a cell

Cimjet's original post explained where to place the code......in
Thisworkbook module.

I simply added a caveat about using close event rather than save
event.


Gord

On Wed, 14 Sep 2011 18:34:58 -0500, "Clif McIrvin"
wrote:

"Alan R" wrote in message
...
or is there a way to have the value change on close



that question was answered, I believe, in a post by Gord earlier.

The macro needs to be posted into the "This Workbook" module not the
worksheet module ... so when you right click on the sheet tab and "view
Code", you need to then select the "this workbook" module before pasting
the sample code.

I believe there is a project manager pane open on the left side of the
screen by default that will show the different modules. If it is not
showing, check the options under the View menu.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default macro to a number + 1 to a cell

Hi Gord
Actually it's a good warning and something for him to consider but sometime they
need to experience it for themselves

"Gord" wrote in message
...
Cimjet's original post explained where to place the code......in
Thisworkbook module.

I simply added a caveat about using close event rather than save
event.


Gord

On Wed, 14 Sep 2011 18:34:58 -0500, "Clif McIrvin"
wrote:

"Alan R" wrote in message
...
or is there a way to have the value change on close



that question was answered, I believe, in a post by Gord earlier.

The macro needs to be posted into the "This Workbook" module not the
worksheet module ... so when you right click on the sheet tab and "view
Code", you need to then select the "this workbook" module before pasting
the sample code.

I believe there is a project manager pane open on the left side of the
screen by default that will show the different modules. If it is not
showing, check the options under the View menu.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default macro to a number + 1 to a cell

I must be doing something wrong since i
Changed sheet name to qoute then i right
clicked on the word quote and opened vba
selected worksheet and pasted


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Quote").Range("H12").Value = Sheets("Quote").Range("H12").Value + 1
ThisWorkbook.Save
End Sub

then i hit save and closed the work sheet and the value stayed the same
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default macro to a number + 1 to a cell

Alan
You right click on the sheet tab then select View Code, but before pasting the
script, you must select "This Workbook".
Don't paste in the Worksheet. In the VBA Project on the left side, select "This
Workbook" by double clicking on it.
The script will update your number before you close your workbook and it will
save it.
You may want to read Gord's comment before proceeding.
HTH
Cimjet
"Alan R" wrote in message
...
I must be doing something wrong since i
Changed sheet name to qoute then i right
clicked on the word quote and opened vba
selected worksheet and pasted


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Quote").Range("H12").Value = Sheets("Quote").Range("H12").Value + 1
ThisWorkbook.Save
End Sub

then i hit save and closed the work sheet and the value stayed the same


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default macro to a number + 1 to a cell

Thank you all for your assistance in helping me with the proper macro on my excel sheet. After reading everyones response and using all your advices I was able to get the sheet the way I wanted it.
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default macro to a number + 1 to a cell

You're welcome
Thanks for the feedback
"Alan R" wrote in message
...
Thank you all for your assistance in helping me with the proper macro on my
excel sheet. After reading everyones response and using all your advices I
was able to get the sheet the way I wanted it.




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
Macro to tell if Cell is Text or Number Donkin[_6_] Excel Programming 3 June 7th 05 02:49 PM
Macro to know if Cell is Text or Number Donkin[_7_] Excel Programming 1 June 7th 05 01:23 PM
macro adding a number to a number already in a cell Tom Ogilvy Excel Programming 0 October 18th 03 04:34 PM
macro adding a number to a number already in a cell Don Guillett[_4_] Excel Programming 0 October 17th 03 05:21 PM
macro adding a number to a number already in a cell Ron de Bruin Excel Programming 0 October 17th 03 04:59 PM


All times are GMT +1. The time now is 04:01 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"