Hide/Unhide macro

leojez

Board Regular
Joined
Apr 12, 2022
Messages
51
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have the following macro that hides selected rows in a table when clicking a shape assigned to the macro:

VBA Code:
Sub Trade_History_Collapse_Table()
'

Range("TableWatchList5911925[#All]").Select
Selection.EntireRow.Hidden = True

End Sub

This works fine. However, I want to add the following so when the same shape is clicked it unhides the selected rows:

VBA Code:
Selection.EntireRow.Hidden = False

I can't seem to figure it out, Any help much appreciated!

Thanks.
 
Select the shape & in the name box (to the left of the formula bar enter the name of the table (without the word table) & then you can use
VBA Code:
Sub Trade_History_Collapse_Table()
   With ActiveSheet.Shapes(Application.Caller)
      With Range("Table" & .Name & "[#All]")
         .EntireRow.Hidden = Not .EntireRow.Hidden
      End With
   End With
End Sub
Amazing, that works really well! Thank you!!
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You're welcome & thanks for the feedback.
 
Upvote 0
Select the shape & in the name box (to the left of the formula bar enter the name of the table (without the word table) & then you can use
VBA Code:
Sub Trade_History_Collapse_Table()
   With ActiveSheet.Shapes(Application.Caller)
      With Range("Table" & .Name & "[#All]")
         .EntireRow.Hidden = Not .EntireRow.Hidden
      End With
   End With
End Sub
Amazing it works really well - thanks!
 
Upvote 0
I know, you said that in post#11 ;)
 
Upvote 0

Forum statistics

Threads
1,215,156
Messages
6,123,339
Members
449,098
Latest member
thnirmitha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top