VBA to Hide Column / Rotate Shape

User2000

New Member
Joined
Oct 10, 2016
Messages
8
Hi,

I have a Column F that is defaulted to be hidden. I have an arrow that is rightward facing and if I click on it, I want Column F to be shown and the arrow to rotate to face leftward. Then if I click on it again, Column F is hidden again and the arrow becomes rightward facing.

I have the code below which works individually for each, but when I combine to 1 macro they cancel each other out so to speak. Any ideas how I get around this to accomplish what I described above?

Thanks!

Sub ExpandColumnF()
If Shapes("Shape1").Rotation = 0 Then
Range("ColumnF").Select
Range("ColumnF").EntireColumn.Hidden = False
Shapes("Shape1").Rotation = 180
Range("E1").Select
End If

End Sub


Sub ContractColumnF()
If Shapes("Shape1").Rotation = 180 Then
Range("ColumnF").Select
Range("ColumnF").EntireColumn.Hidden = True
Shapes("Shape1").Rotation = 0
Range("E1").Select
End If
End Sub


Sub ColumnF()
ExpandColumnF
ContractColumnF
End Sub
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I think all you need is this:

Code:
Sub ExpandColumnF()
'Modified 1-24-18 2:45 PM EST
If ActiveSheet.Shapes.Range("Shape1").Rotation = 0 Then
    ActiveSheet.Range("F1").EntireColumn.Hidden = False
    ActiveSheet.Shapes.Range("Shape1").Rotation = 180
Else
    If ActiveSheet.Shapes.Range("Shape1").Rotation = 180 Then
    ActiveSheet.Range("F1").EntireColumn.Hidden = True
    ActiveSheet.Shapes.Range("Shape1").Rotation = 0
    End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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