Worksheet- activate macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Each time the sheet is activated I want it to return the next proposal
number. So that I open it, type proposal (number 1234)- print and exit. Then
later I open the sheet again and the proposal number changes to 1235. I hope
this is more clear. I tried the macro. Copied and pasted it into the code as
you explained. It didn't work though.
 
You mean you want this to happen when you open the workbook--not activate a
sheet within that workbook?

If yes, this goes behind the ThisWorkbook module (not behind the worksheet, not
in a general module):

Option Explicit
Sub Workbook_Open()
with me.worksheets("whateversheetholdsthecounter").range("a1")
.value = .value + 1
.printout
end with

me.save
me.close savechanges:=false
End sub

This will open, add one to a cell, print that worksheet, save the workbook and
close the workbook.

You may not want to include the .close statement. It could make it difficult to
test/change.
 
How do I access the workbook module?
Sorry, this is pretty far above my skill level. But everytime I (or someone
else on my network) access the 'Proposal #2" I want the proposal number (cell
K2) to add one.
 
Open the VBE (where macros live)
Hit ctrl-r to see the project explorer (like windows explorer)
select your workbook's project
Use the + to expand the objects
look for ThisWorkbook and double click on it.

Paste the code in that newly opened code window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top