#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Show all data

I have a search facility which filters the data, That works ok, but when I
press commandbutton1 (code below) it should show all data and change to
sheet7. I get an error code 1004 and the following is highlighted
"Sheet1.ShowAllData".
Any ideas?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Sheet1.ShowAllData
Cells.Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default Show all data

Hi

You have to refer to a range, ie Selection.ShowAllData.
If you want to turn off the filter use Selection.AutoFilter.

Btw: You don't need to write Cells.Range("A1")... , just use Range("A1")...

Regards,
Per

"WH99" skrev i meddelelsen
...
I have a search facility which filters the data, That works ok, but when I
press commandbutton1 (code below) it should show all data and change to
sheet7. I get an error code 1004 and the following is highlighted
"Sheet1.ShowAllData".
Any ideas?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Sheet1.ShowAllData
Cells.Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Show all data

Thanks for coming back so quickly.
Would the code look something like what I have below?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Selection.ShowAllData
Selection.AutoFilter
Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99


"Per Jessen" wrote:

Hi

You have to refer to a range, ie Selection.ShowAllData.
If you want to turn off the filter use Selection.AutoFilter.

Btw: You don't need to write Cells.Range("A1")... , just use Range("A1")...

Regards,
Per

"WH99" skrev i meddelelsen
...
I have a search facility which filters the data, That works ok, but when I
press commandbutton1 (code below) it should show all data and change to
sheet7. I get an error code 1004 and the following is highlighted
"Sheet1.ShowAllData".
Any ideas?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Sheet1.ShowAllData
Cells.Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Show all data


Try...
If Sheet1.FilterMode Then Sheet1.ShowAllData
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"WH99"
<wrote in message
I have a search facility which filters the data, That works ok, but when I
press commandbutton1 (code below) it should show all data and change to
sheet7. I get an error code 1004 and the following is highlighted
"Sheet1.ShowAllData".
Any ideas?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Sheet1.ShowAllData
Cells.Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Show all data

So commandbutton1 is on Sheet1?

If yes:

Private Sub CommandButton1_Click()
with me
.Unprotect
If .FilterMode Then
.ShowAllData
End If
.range("a1").select
.protect
end with
Sheet7.select
worksheets("Menu").commandbutton3.visible = true
end sub

Is there any reason you used the codename for Sheet7, but worksheets("menu") for
the visible statement?

If Sheet1 is not the sheet with the button:


Private Sub CommandButton1_Click()
with Sheet1
.Unprotect
If .FilterMode Then
.ShowAllData
End If
.select 'need to select the sheet before selecting a range
.range("a1").select
.protect
end with
Sheet7.select
worksheets("Menu").commandbutton3.visible = true
end sub


WH99 wrote:

I have a search facility which filters the data, That works ok, but when I
press commandbutton1 (code below) it should show all data and change to
sheet7. I get an error code 1004 and the following is highlighted
"Sheet1.ShowAllData".
Any ideas?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Sheet1.ShowAllData
Cells.Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default Show all data

Thanks for your reply.

It looks fine, but you have to test it, to see if it's ok.

The Selection.ShowAllData will only work if the range where the filter is
applied is selected, otherwise refer to the eact range.

Regards,
Per

"WH99" skrev i meddelelsen
...
Thanks for coming back so quickly.
Would the code look something like what I have below?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Selection.ShowAllData
Selection.AutoFilter
Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Show all data

Per, Jim and Dave,
Thank you all for your surgestions.
I tried Dave`s code and it work well.....thanks Dave.
I`ll stay with that one.
--
WH99


"Dave Peterson" wrote:

So commandbutton1 is on Sheet1?

If yes:

Private Sub CommandButton1_Click()
with me
.Unprotect
If .FilterMode Then
.ShowAllData
End If
.range("a1").select
.protect
end with
Sheet7.select
worksheets("Menu").commandbutton3.visible = true
end sub

Is there any reason you used the codename for Sheet7, but worksheets("menu") for
the visible statement?

If Sheet1 is not the sheet with the button:


Private Sub CommandButton1_Click()
with Sheet1
.Unprotect
If .FilterMode Then
.ShowAllData
End If
.select 'need to select the sheet before selecting a range
.range("a1").select
.protect
end with
Sheet7.select
worksheets("Menu").commandbutton3.visible = true
end sub


WH99 wrote:

I have a search facility which filters the data, That works ok, but when I
press commandbutton1 (code below) it should show all data and change to
sheet7. I get an error code 1004 and the following is highlighted
"Sheet1.ShowAllData".
Any ideas?

Option Explicit

Private Sub CommandButton1_Click()
Sheet1.Unprotect
Sheet1.ShowAllData
Cells.Range("A1").Select
Sheet1.Protect
Sheet7.Select
Worksheets("menu").CommandButton3.Visible = True
End Sub
--
WH99


--

Dave Peterson

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
show 3 sets of data per data point in a scatter plot Marie Charts and Charting in Excel 6 May 19th 08 09:38 PM
how do i sort a worksheet data to show repetitve data and show mrcheatherington Excel Worksheet Functions 1 December 30th 07 02:26 PM
Don't Show Zero Data dot Charts and Charting in Excel 1 October 23rd 06 11:31 PM
Can you show data in a data table but not plot it on the chart? Armadillo Charts and Charting in Excel 2 May 19th 05 01:08 PM
HOW DO I HIDE DATA AND SHOW A PLUS SIGN THAT I HAVE HIDDEN DATA H. tory Excel Discussion (Misc queries) 1 December 27th 04 09:54 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"