Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I reduce 10 Sub() into 1 Sub()?
Hi Each button has to have an underlying macro to function, but you could put your code in a seperat sub which is called from each button macro (CentralCode should in an ordinary module): Private Sub cmdCentralPA_Click() Call CentralCode End Sub Sub CentralCode() Dim btnCaption As String Application.DisplayAlerts = False Application.ScreenUpdating = False btnCaption = Me.cmdCentralPA.Caption Call unhideSheets Call getMarketdata(btnCaption) Call hideShapes Me.Range("A2").Select Application.ScreenUpdating = True Application.DisplayAlerts = True End Sub Hopes this helps. .... Per "Ayo" skrev i meddelelsen ... I have this subroutine that I have to repeat 10 times on a worksheet: Private Sub cmdCentralPA_Click() Dim btnCaption As String Application.DisplayAlerts = False Application.ScreenUpdating = False btnCaption = Me.cmdCentralPA.Caption Call unhideSheets Call getMarketdata(btnCaption) Call hideShapes Me.Range("A2").Select Application.ScreenUpdating = True Application.DisplayAlerts = True End Sub i.e., Private Sub cmdConnecticut_Click(), Private Sub cmdLongIsland_Click(), Private Sub cmdNewEngland_Click(), Private Sub cmdNewJersey_Click() etc. I am looking for a code that will determine which button was click and then run the code based on that button. Instead of repeating the same subroutine 10 times. Any ideas? Thanks Ayo |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not reduce fractions | Excel Discussion (Misc queries) | |||
Can I reduce (101.25) to only what's *right* of decimal? (25) | Excel Worksheet Functions | |||
How to Reduce value in a column by 5%? | Excel Discussion (Misc queries) | |||
reduce if statements | Excel Programming | |||
How to reduce table? | New Users to Excel |