Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
show all the rows before closing the document
Hi.
How can I prevent to close worksheet when it is used filter (4 example: for sorting by name)? I need to have always all the rows visible when it is going to be closed. Please help me. Many thanks. Peter |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
show all the rows before closing the document
Hello Peter
Paste and amend this code with correct sheet name into Thisworkbook module: Private Sub Workbook_BeforeClose(Cancel As Boolean) With Worksheets("Sheet1") If .AutoFilterMode Then ..ShowAllData: End If: End With Me.Save End Sub HTH Cordially Pascal "Peter KNAP" a écrit dans le message de news: ... Hi. How can I prevent to close worksheet when it is used filter (4 example: for sorting by name)? I need to have always all the rows visible when it is going to be closed. Please help me. Many thanks. Peter |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
show all the rows before closing the document
Need to amend with error handling just in case:
Private Sub Workbook_BeforeClose(Cancel As Boolean) With Worksheets("Sheet1") If .AutoFilterMode Then On Error Resume Next ..ShowAllData On Error GoTo 0 End If End With Me.Save End Sub HTH Cordially Pascal "papou" a écrit dans le message de news: ... Hello Peter Paste and amend this code with correct sheet name into Thisworkbook module: Private Sub Workbook_BeforeClose(Cancel As Boolean) With Worksheets("Sheet1") If .AutoFilterMode Then .ShowAllData: End If: End With Me.Save End Sub HTH Cordially Pascal "Peter KNAP" a écrit dans le message de news: ... Hi. How can I prevent to close worksheet when it is used filter (4 example: for sorting by name)? I need to have always all the rows visible when it is going to be closed. Please help me. Many thanks. Peter |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
show all the rows before closing the document
Hi
papou. thank you the code does what I have asked for however one problem occurs. when I open the worksheet only for information, use filter but accidentaly change some cell or delete it excel does not ask me whether I want to save changes or not. €žpapou" napÃ*sal (napÃ*sala): Need to amend with error handling just in case: Private Sub Workbook_BeforeClose(Cancel As Boolean) With Worksheets("Sheet1") If .AutoFilterMode Then On Error Resume Next ..ShowAllData On Error GoTo 0 End If End With Me.Save End Sub HTH Cordially Pascal "papou" a écrit dans le message de news: ... Hello Peter Paste and amend this code with correct sheet name into Thisworkbook module: Private Sub Workbook_BeforeClose(Cancel As Boolean) With Worksheets("Sheet1") If .AutoFilterMode Then .ShowAllData: End If: End With Me.Save End Sub HTH Cordially Pascal "Peter KNAP" a écrit dans le message de news: ... Hi. How can I prevent to close worksheet when it is used filter (4 example: for sorting by name)? I need to have always all the rows visible when it is going to be closed. Please help me. Many thanks. Peter |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
show all the rows before closing the document
Peter:
To make sure that Excel prompts you to save ANY changes to the file, delete the "Me.Save" line in the code previously offered. Change Worksheets("Data") to be the name of your worksheet. Try the following code (make sure it is in the "ThisWorkbook" module): Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim wsData As Worksheet On Error Resume Next Set wsData = Worksheets("Data") With wsData .ShowAllData 'Needed in case Advanced Filter is used. .AutoFilterMode = False 'Turn off AutoFilter drop-down arrows. End With 'Display the unfiltered worksheet while 'the Save dialog box is being displayed. Application.ScreenUpdating = True End Sub -- Regards, Bill Renaud |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
show all the rows before closing the document
Thank you both. with some amendments it works well.
Peter €žBill Renaud" napÃ*sal (napÃ*sala): Peter: To make sure that Excel prompts you to save ANY changes to the file, delete the "Me.Save" line in the code previously offered. Change Worksheets("Data") to be the name of your worksheet. Try the following code (make sure it is in the "ThisWorkbook" module): Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim wsData As Worksheet On Error Resume Next Set wsData = Worksheets("Data") With wsData .ShowAllData 'Needed in case Advanced Filter is used. .AutoFilterMode = False 'Turn off AutoFilter drop-down arrows. End With 'Display the unfiltered worksheet while 'the Save dialog box is being displayed. Application.ScreenUpdating = True End Sub -- Regards, Bill Renaud |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Updating Document Without Closing and Re-Opening | Excel Discussion (Misc queries) | |||
Userform won't show after closing another file | Excel Discussion (Misc queries) | |||
Re-show userform after closing file - code help | Excel Discussion (Misc queries) | |||
How do I undo changes after saving and closing a document | Setting up and Configuration of Excel | |||
closing a word document | Excel Programming |