Toggle Macro with KeyStrokes

C

Cesar Zapata

Hi guys,


I have a macro that unhides and hides some columns. I have a button that
toggles the macro depending on the label of the button.

But cause a button takes too much space,( I have other buttons there too) I
would like to know if there is a way to program a combination of keystrokes
to handle my macro. for example CTRL + "-" will hide columns and CTRL + "+"
will unhide them.


the simple current macro look like this.


Sub hide()
Dim x As String
Dim cell As Range
If ActiveSheet.Buttons(Application.Caller).Caption = "Select Store" Then
x = InputBox("Please insert the store 3 letters initials. ie. GRW or FRA",
"This a test only")
x = UCase(x)
If x = "" Then
Exit Sub

Else

If Len(x) > 3 Then
MsgBox "Please only 3 letters"
Else

Range("v1").Select
For Each cell In Range("v1:CL1")
If Left(cell.Value, 3) <> x Then

cell.EntireColumn.Hidden = True



End If

Next cell
ActiveSheet.Buttons(1).Caption = "Show All"
End If
End If

Else

If ActiveSheet.Buttons(Application.Caller).Caption = "Show All" Then

Range("v1:CL1").EntireColumn.Hidden = False

ActiveSheet.Buttons(Application.Caller).Caption = "Select Store"


End If

End If

end sub



Gracias for you help.

Cesar........
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top