you can, when you put the button in right click it, go to format controls, Properties tab, select don't move or size with cells
also you could put the buttons all in the A column since you are hiding columns, then they will never disappear
otherwise you can use something like this on the actual sheet (double click the sheet in the VBA editor):
Private Sub Worksheet_Change(ByVal Target As Range)
'this macro uses a drop down (arbitrarily placed in cell E1 for this demo) to hide given columns based on the value shown in the
'drop down the values used are HideRevenue, HideMax, HideVolume, and Show All (I used Show All since you can do that then hide another
'just as easily as selecting ShowRevenue etc.
If Target.Address = "$E$1" Then
If Range("$E$1").Value = "HideRevenue" Then
Cells.EntireColumn.Hidden = False
Columns("I:L").EntireColumn.Hidden = True
End If
If Range("$E$1").Value = "HideMax" Then
Cells.EntireColumn.Hidden = False
Columns("M:S").EntireColumn.Hidden = True
End If
If Range("$E$1").Value = "HideVolume" Then
Cells.EntireColumn.Hidden = False
Range("T:T,X:Z,AF:AF").EntireColumn.Hidden = True <---note for multiple columns that are noncontiguous use range()
End If
If Range("$E$1").Value = "Show All" Then
Cells.EntireColumn.Hidden = False
End If
End If
End Sub
Bookmarks