Bright01
asked on
Integrating two macros into one
I have a great little form/macro that byandt wrote for me that keeps an option to edit and return visible in a spreadsheet. The challenge I have is I have two macros that need to be placed into the form/macro and I don't know how to incorporate them into what was sent.
Thanks in advance,
B.
Moving-Buttons-with-the-cellsQ28721.xlsm
Thanks in advance,
B.
Moving-Buttons-with-the-cellsQ28721.xlsm
Where do you want the two macros to run? There's no code in the UserForm except two test messages.
As Roy implied it's hard to tell what macro's you want to run. One thing I can say is that if one is called Macro1 and the other is called Macro2 then a 3rd macro can be written like this that will run them both.
Sub Macro3()
' Run Macro1
Macro1
'Run Macro2
Macro2
End Sub
Hi,
pls try ( inthe form module)
pls try ( inthe form module)
Option Explicit
Private Sub CommandButton1_Click()
'Private Sub CommandButton2_Click()
'If CommandButton1.Caption = "Display More" Then
If CommandButton1.Caption = "Display Questions" Then
'Your two macros look the same to me except for the name, but
'reguardless you would put the name of the one that you want to
'run when the caption says "Expand" here
Contract_All '
' Else
'Expand_All
Else
If CommandButton1.Caption = "Display Details" Then
'Your two macros look the same to me except for the name, but
'reguardless you would put the name of the one that you want to
'run when the caption says "Expand" here
Expand_All
Else
If CommandButton1.Caption = "Display More Detail" Then
'Your two macros look the same to me except for the name, but
'reguardless you would put the name of the one that you want to
'run when the caption says "Expand" here
Details_All
End If
End If
End If
End Sub
Private Sub CommandButton2_Click()
Run 'G:\PC Dev Data\PCI Workbench\PCI Workbench v113.xlsm'!Sheet34.ReturntoDirections_Click
End Sub
Sub Contract_All()
'ActiveSheet.Unprotect Password:="jam"
ActiveSheet.Outline.ShowLevels Rowlevels:=1
'ActiveSheet.Protect Password:="jam"
ActiveSheet.EnableSelection = xlUnlockedCells
CommandButton1.Caption = "Display Details"
Range("A3").Activate
End Sub
Sub Expand_All()
'ActiveSheet.Unprotect Password:="jam"
ActiveSheet.Outline.ShowLevels Rowlevels:=2
'ActiveSheet.Protect Password:="jam"
ActiveSheet.EnableSelection = xlUnlockedCells
CommandButton1.Caption = "Display More Detail"
Range("A3").Activate
End Sub
Sub Details_All()
'ActiveSheet.Unprotect Password:="jam"
ActiveSheet.Outline.ShowLevels Rowlevels:=3
'ActiveSheet.Protect Password:="jam"
ActiveSheet.EnableSelection = xlUnlockedCells
CommandButton1.Caption = "Display Questions"
Range("A3").Activate
End Sub
Sub ReturntoDirections_Click()
'This brings up the Directions for review
Sheet34.Visible = xlSheetHidden
Sheet25.Visible = xlSheetVisible
Sheet25.Activate
End Sub
Regards
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great Teamwork to all! This was a horrible "ask" with little detail. And sorry for being "off the grid" for several days. In the end, it worked....... required a little trouble shooting to incorporate it but you guys did great and helped me learn more about how to use Forms!
Much thanks,
B.
Much thanks,
B.