View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cesar Zapata[_2_] Cesar Zapata[_2_] is offline
external usenet poster
 
Posts: 66
Default Toggle Macro with KeyStrokes

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........