Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have own CommandBar "MyMenu" with three msoCommandButton. Each
CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Parameter is what you're after.
I have CommandBar Button examples on my website. -- Rob van Gelder - http://www.vangelder.co.nz/excel "JosephVBA" wrote in message ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try again... post seems to delete itself from the server.
--- Parameter is what you're after. I have CommandBar Button examples on my website. -- Rob van Gelder - http://www.vangelder.co.nz/excel "JosephVBA" wrote in message ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Joseph;
Select Case Application.Caller(1) Case 1 '... case 2 '... Case 3 '... End Select MP "JosephVBA" a écrit dans le message de ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, it seems like a good solution. I`ll try it later.
|
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think the best answer is
set cb = CommandBars.ActionControl If you need a case statement you could use Userform1.Load Select Case cb.Caption Case "Button1" Userform1.Listbox1.RowSource = "Sheet1!A1:A10" Case "Button2" Userform1.Listbox1.RowSource = "Sheet1!B1:B10" End Select Userform1.Show -- Regards, Tom Ogilvy "JosephVBA" wrote in message ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If pressed no to msgbox, then exit sub | Excel Programming | |||
Delete is Pressed then Stop | Excel Programming | |||
Which button was pressed? | Excel Programming | |||
Errormessage when button is pressed twice or more | Excel Programming | |||
Trapping key pressed in a worksheet | Excel Programming |