Hide worksheets before close

I have a workbook with multiple sheets that I would like to Hide before
close.  I am using a macro attached to a "Quit" button, but it does not
work.
I also have a Sub in ThisWorkbook, but I can't seem to call it

Sub Button14_Click_Quit()

    Application.DisplayAlerts = False

    Worksheets("A Detail").Visible = False
    Worksheets("A Metrics").Visible = False
    Worksheets("B DV Detail").Visible = False
    Worksheets("B DV Metrics").Visible = False
    Worksheets("B Detail").Visible = False
    Worksheets("B Metrics").Visible = False
    Worksheets("C Metrics").Visible = False
    Worksheets("C Detail").Visible = False
    Worksheets("D Detail").Visible = False
    Worksheets("D Metrics").Visible = False

    Workbooks("KeyCustomerMetrics.XLS").Close


End Sub


The code in ThisWorkbook:

Public Sub Workbook_BeforeClose(Cancel As Boolean)

    Worksheets("A Detail").Visible = False
    Worksheets("A Metrics").Visible = False
    Worksheets("B DV Detail").Visible = False
    Worksheets("B DV Metrics").Visible = False
    Worksheets("B Detail").Visible = False
    Worksheets("B Metrics").Visible = False
    Worksheets("C Metrics").Visible = False
    Worksheets("C Detail").Visible = False
    Worksheets("D Detail").Visible = False
    Worksheets("D Metrics").Visible = False
End Sub

If I click on File, Close, it works--not sure what i am doing wrong....
any help would be much appreciated

J

0
JoeleneW1 (2)
4/26/2006 4:39:45 PM
excel.newusers 15348 articles. 2 followers. Follow

2 Replies
679 Views

Similar Articles

[PageSpeed] 31

You can't just make up event procedure names. You must use the 
event names provided by VBA. Assuming your button is named 
Button14, change

Sub Button14_Click_Quit()
to
Sub Button14_Click()


-- 
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


<JoeleneW@gmail.com> wrote in message 
news:1146069585.728014.227750@t31g2000cwb.googlegroups.com...
>I have a workbook with multiple sheets that I would like to Hide 
>before
> close.  I am using a macro attached to a "Quit" button, but it 
> does not
> work.
> I also have a Sub in ThisWorkbook, but I can't seem to call it
>
> Sub Button14_Click_Quit()
>
>    Application.DisplayAlerts = False
>
>    Worksheets("A Detail").Visible = False
>    Worksheets("A Metrics").Visible = False
>    Worksheets("B DV Detail").Visible = False
>    Worksheets("B DV Metrics").Visible = False
>    Worksheets("B Detail").Visible = False
>    Worksheets("B Metrics").Visible = False
>    Worksheets("C Metrics").Visible = False
>    Worksheets("C Detail").Visible = False
>    Worksheets("D Detail").Visible = False
>    Worksheets("D Metrics").Visible = False
>
>    Workbooks("KeyCustomerMetrics.XLS").Close
>
>
> End Sub
>
>
> The code in ThisWorkbook:
>
> Public Sub Workbook_BeforeClose(Cancel As Boolean)
>
>    Worksheets("A Detail").Visible = False
>    Worksheets("A Metrics").Visible = False
>    Worksheets("B DV Detail").Visible = False
>    Worksheets("B DV Metrics").Visible = False
>    Worksheets("B Detail").Visible = False
>    Worksheets("B Metrics").Visible = False
>    Worksheets("C Metrics").Visible = False
>    Worksheets("C Detail").Visible = False
>    Worksheets("D Detail").Visible = False
>    Worksheets("D Metrics").Visible = False
> End Sub
>
> If I click on File, Close, it works--not sure what i am doing 
> wrong....
> any help would be much appreciated
>
> J
> 


0
chip1 (1821)
4/26/2006 4:44:06 PM
Guess I should explain better.
I created the button using the Forms toolbar, then right-clicked to
assign macro. I created the macro and re-named it, and that is where
the name came from.
The workbook closed when i clicked the button, but the sheets did not
hide.
I re-named the procedure and re-assigned the button macro, but still,
the sheets remained visible.

Got it--as i worked on it, i realized that i didn't save before
close....now it works

thanks for the help,--your website is great, by the way

J

0
JoeleneW1 (2)
4/26/2006 6:25:04 PM
Reply:

Similar Artilces:

Hiding "0" values in pivot table
In a worksheet I have a listing of stock records with ItemNumber, Date, StockLocation and NumberOnStock. When I make simple Pivot Table with ItemNumber and StockLocation as rows and select a Sum of "NumberOnStock" I would like to hide rows where the sum is "0". But this does not seem to be possible. Tried to follow the guidelines in the Microsoft article: http://office.microsoft.com/en-us/assistance/HP051998791033.aspx#Hide%20zero%20values%20in%20a%20PivotTable%20report But no luck :-( Mogens You could use conditional formatting on these cells - highlight the cells,...

Hiding formuals in cells question
Hi. I was wondering if there was a way to hide the formulas in cells without protecting the sheet. I am making something for other teachers at my school and I want to hide the formulas so they won't mess anything up on the spreadsheet. Any help would be greatly appreciated. Thanks! Hi not without protecting the sheet but why is this a problem for you? -- Regards Frank Kabel Frankfurt, Germany "JP" <JP@discussions.microsoft.com> schrieb im Newsbeitrag news:ABFE07BF-6087-4E24-814A-03AF8863A633@microsoft.com... > Hi. I was wondering if there was a way to hide the fo...

Emailing a Worksheet
Is it possible to email a single worksheet in such a way that th recepient can make changes to the worksheet and send it back to me? I so, can I then replace the existing worksheet with the revise worksheet I receive back? Thanks for any help. (I'm looking to avoi having to send an entire workbook -- Message posted from http://www.ExcelForum.com Hi have a look at the following site for some example code http://www.rondebruin.nl/sendmail.htm#Sheet -- Regards Frank Kabel Frankfurt, Germany > Is it possible to email a single worksheet in such a way that the > recepient can make...

hide my name
When replying to an email or creating one from scratch how do i hide my name in the "from" field...thx fred <fdbjrgetridofthis@wowway.com> wrote: > When replying to an email or creating one from scratch how do i hide > my name in the "from" field...thx Are you saying you want the reply to be anonymous? -- Brian Tillman [MVP-Outlook] no, I don't mind if my email is revealed.. just my name. I have tried by removing it from the "User Name:" field in the email account but it continues to show up. I have also removed from the header informati...

no love from hq client unless you use a 401 Worksheet?
hi all, for some stores in our business certain information won't get sent to our HQ database even after syncing up using the client....unless i first create a 401 Data Upload worksheet first. i'm positive it's something going wrong. consider these 2 examples: (1) i create a transfer in Store A going to Store B, then sync with HQ. HQ sees the transfer from Store A but refuses to send the transer to Store B unless I first send a 401 Worksheet to Store B. Then and only then will the transfer go through. I posted about this issue before, and beleive me it's not a configuration is...

Shared Worksheet
Hello All, I have 5 users in my warehouse that have a shared worksheet that all members can make changes. This is working well except for 1 item. When someone makes a change all of the others do a ctrl+s to update what changes were made but this is a truck loading list and the others update OK but the save does not put the list in the proper order. If someone inserted a line in the middle and saved, the other users see it on the first line not the intended line. The cells that have been added and changed also shows a small triangle in the corner of the cell. The question is how do we hav...

Macro to copy Excel values between worksheets
hi, I have use the Excel Tip Copy a column or columns from each sheet into one sheet using VBA in Microsoft Excel. I try to use the copy values A5:A20 and IQ5:IT20 from sheet 1 to Sheet 2. However, when i run the macro, it only copy the value in A5:A20 to Sheet2. There are formulas (SUM) used in IQ5:IT20. How can I modify the macro to copy the two ranges of value into another sheet? Will the format of the cells influence the results? Please help me asap. Thankyou very much! +----------------------------------------------------------------+ | Attachment file...

Hiding and Un-Hiding Data fields
I am using a form for people to select data via dropdown menus and then having it run through a query to filter results. Is there a way that I can have certain feilds hidden until a toggle button or something of the like is clicked? Basically I want have three choices of buttons: Year, Quarter, and Month. What I ideally want to happen is when someone selects the button for year, a hidden drop down menu appears where they can then choose from the available years to filter through the query. I would say I am above average with using access, but I have no idea how to hide fields and then...

How do I hide gaps in an Excel 2007 chart?
I have a bar chart that is showing gaps and i don't want them. The select data > hidden and empty cell button does not give an option to hide gaps. I think by default they are hidden but if you even click on this to see what it does the gaps are shown and no way to turn off. Hi, If you hide the actual rows then with the Plot visible cells only setting on the gaps will be removed. In xl2007 the setting is on the Select Data dialog, Hidden/empty cells button. Cheers Andy Waynesch wrote: > I have a bar chart that is showing gaps and i don't want them. The s...

Put Active Worksheet's Name in a Cell #3
Is there a way to put the active worksheet's name in the cell? Not the file name of the whole workbook, just the name of the currently selected sheet. Thanks for your help. Hi Corey, There are a few ways this can be done using either macros or functions, here's one of each: *=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1, LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1))) (sourced from Chip Pearson's site, http://www.cpearson.com/excel/excelF.htm) I recommend checking this page out as it also shows ot...

Hiding a worksheet #3
I want to hide a worksheet. So, I went to the format menu and the "worksheet" option is grayed out. Why? And, how do I "ungray" it. Hi is your worksheet protected ? -- Regards Frank Kabel Frankfurt, Germany llong wrote: > I want to hide a worksheet. So, I went to the format menu and the > "worksheet" option is grayed out. Why? And, how do I "ungray" it. I think Frank meant to ask about the Workbook--not the worksheet. (Check under Tools|protection|Protect workbook or Unprotect workbook) My question is: Is there another sheet in the w...

Hide images when Hiding Rows
I have inserted images into cells, but when I hide the column the images are not hidden with that column, they just get squished between the two cells next to the hidden cell. Is there a setting or way to tie the image to that cell so that it hides/unhides appropriately with the row? -- kurt ------------------------------------------------------------------------ kurt's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=35686 View this thread: http://www.excelforum.com/showthread.php?threadid=554712 Kurt You cannot insert an image into a cell. You can overlay ...

Copying and numbering worksheets
I am trying to set up a new purchase ordering system using Excel. I am trying to set up a macro which will copy the master worksheet and number it as the next PO is needed. We have a separate workbook for each job and PO's are listed as XY-001, XY-002 ,... ...

how to hide an ActiveX control?
hi there i have an ActiveX control, written in C++, which has the OLEMISC_INVISIBLEATRUNTIME flag set, yet when i display the web page it is attached to, i get the familiar "red cross" graphic in the middle of the screen - how can i hide the control so nothing is displayed at all? tia bhu can u set the size of ur control as 1x1 pixels "bhu Boue vidya" <bhuvidya@yahoo.com.au> wrote in message news:1175703214.292931.252210@e65g2000hsc.googlegroups.com... > > hi there > > i have an ActiveX control, written in C++, which has the > OLEMISC_INVISIBLEATR...

Outlook hangs up and won't close completely
After using Outlook, and closing via the "X" in upper right, the program does not close. I can check and confirm this via Task Manager. When I then try to shut down the system, I get the "please wait" advisory, while TM shuts down Outlook. This can take a bit, as sometimes there may be 5-6 instances of Outlook "running" in the TM processes tab, with sizes from 40KB to 16,000+KB. I can shut down the individual outlook processes via TM. Have virus scanned the system (P4 2.2GHz, Win XP Pro). Am also running AOL IM for daughter. TIA, Dave ...

Hiding plot Area
I have a formatted output sheet that has a Pie Chart embedded. The data for the pie chart comes from a second sheet using 2 ranges B2:B6 & D2:D6 B2:B6 is always populated and contains labels. What I want to do is, when D2:D6 contains 0 in each cell (or Null), suppress the Pie chart but always show the Legend (which is driven by B2:B6) Many Thanks Adam Adam - All you see of the pie when all values are zero is a single line at the first slice. The legend still appears. To hide the line, double click on one of the wedges and on the Patterns tab, change the Border setting to None. ...

Summing up data from various worksheets
I have daily data all on different worksheets (31 in total) and I would like to add up all of the data in these worksheets in a monthly compilation I have so far been using the =sum('jan. 1'!B6, 'jan. 2'!B6 ... etc.) which although is effective is very time consuming is there an easier way to sum up all of the b6 cells without entering them individually? Thanks -- mark_vi_ ------------------------------------------------------------------------ mark_vi_'s Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24507 View this thread: http://www.excelf...

Hiding rows with VBA
Hi all, In my sheet called "insertsheet I have this VBA: (thanks to some users of Google groups) Private Sub Worksheet_Change(ByVal Target As Range) Const nMAX As Long = 10 Dim nRows As Long Application.ScreenUpdating = False With Me With .Range("B8") If Intersect(Target(1), .Cells) Is Nothing Then Exit Sub nRows = .Value End With .Range(.Cells(1, 5), .Cells(1, _ .Columns.Count)).EntireColumn.Hidden = True .Range(Cells(1, 5), .Cells(1, _ ...

print 2 worksheets on the same page side-by side
I am creating a template that has two worksheets, I need to print the worksheets on the same page side-by-side. The problem I am having with them on the same page is when I hide the rows with zero values on one side it hides the the numbers on the other side You have a response at your other thread. wil4d wrote: > > I am creating a template that has two worksheets, I need to print the > worksheets on the same page side-by-side. The problem I am having with them > on the same page is when I hide the rows with zero values on one side it > hides the the numbers on the other s...

hiding rows
I have data in cells A7:DK394 which all have 0 in them until totals are added in other worksheets which then pullthrough. At the end of the week I have to Hide all rows from A7 to A394 that still have 0 in them as no totals have been added in other sheets so the customer has not posted with us. is there any way excell can recognise the cells that have no data against them and hide them automatically by pressing a button. or if they all start off hidden unhide as data is entered. Hopefully this makes sense many thanks for any help with this as again its to save me lots of...

Open Worksheet
I have a workbook with several worksheets. On one of my worksheets I have a userform that opens up when that worksheet is selected (Activated). But when the user saves then closes the workbook and the next time the workbook is opened, it opens to that worksheet so the userform does not open. How can I say Activate only if that sheet is active. Add some BeforeClose/Save event code in Thisworkbook module to select another sheet upon closing. Gord Dibben MS Excel MVP On Fri, 15 Oct 2010 17:13:47 -0700 (PDT), Richard <bobdelrn@yahoo.com> wrote: >I have a workbook with several wor...

Outlook-hiding recipients addresses
How do you send a mailing to a distribution list without exposing their email addresses to the other recipients? Put the DL name in the BCC field and put your own address in the TO field. anonymous@discussions.microsoft.com wrote: > How do you send a mailing to a distribution list without > exposing their email addresses to the other recipients? ...

Hide contacts
I must hide some contacts from GAL excepted for 2 user that must to see them and select to send email. If only 2 users need a Contact, why not have them create it in their Contacts folder? -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: www.exchangepedia.com/blog ---------------------------------------------- "MauroR" <MauroR@discussions.microsoft.com> wrote in message news:DAC0E2E9-7389-49F0-8736-3B9251DBB274@microsoft.com... >I must hide some contacts from GAL excepted for 2 user that must to see >them > and select to send email. Th...

How do I hide email addresses in outgoing mail
Hint: You post your question in the body of the post, not the Subject. Hint 2: Use the BCC field. -- Russ Valentine [MVP-Outlook] "Dennis" <Dennis@discussions.microsoft.com> wrote in message news:B2C2A70C-6C94-4688-8BAF-0A50AC9C142D@microsoft.com... > "Dennis" <Dennis@discussions.microsoft.com> wrote in message news:B2C2A70C-6C94-4688-8BAF-0A50AC9C142D@microsoft.com... > PLEASE write your question in the body of the post and NOT just the subject Have a look here: http://dts-l.net/goodpost.htm As posted here MANY MANY times - put them in the BCC...

Can I Hide a Field?
I'm wanting to hide a field on a form (products form in this case) for some users but not for other users. Is this possible? For example, can I hide the product cost (wholesale) of an item for the salesperson, but not for the CEO? -- Brandon IT Director Office Equipment & Supplies at http://www.presentationsdirect.com Hi Brandon, You cannot have different formlayouts for different users/Teams at this time... Regards, Michael Randrup "Brandon S." <bsmith@presentationsdirect.nospam.com> wrote in message news:e4pDiMrYDHA.1620@TK2MSFTNGP12.phx.gbl... > I'm ...