Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have created six macro that sort one of six columns (macro 1 sorts
column by column A, macro 2 sorts by column B, etc. I have created a user form (with option buttons) that allows the user to select if the sorting is Ascending (optAsc) or Descending (optDes), then select an option button (optDealer, optSig, optPO, optInv, optDate and optDue) to decide which of the 6 columns is actually sorted. (See code at bottom for one example.) I can not figure out how to make the action dependant upon which option button is selected. Any ideas? Sub alphabyDealerName() 'macro "Sheet1.alphabySignature" , sorts alphabetical by "Dealer Name(A2)" Range("Database").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub (I know that I can change xlAscending to xlDescending to swap directions) TIA |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Is it dependant based on a checkbox, drop down, optionbutton? Sounds like a Select Case or a If Then is necessary. L Scholes Wrote: I have created six macro that sort one of six columns (macro 1 sorts column by column A, macro 2 sorts by column B, etc. I have created a user form (with option buttons) that allows the user to select if the sorting is Ascending (optAsc) or Descending (optDes), then select an option button (optDealer, optSig, optPO, optInv, optDate and optDue) to decide which of the 6 columns is actually sorted. (See code at bottom for one example.) I can not figure out how to make the action dependant upon which option button is selected. Any ideas? Sub alphabyDealerName() 'macro "Sheet1.alphabySignature" , sorts alphabetical by "Dealer Name(A2)" Range("Database").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub (I know that I can change xlAscending to xlDescending to swap directions) TIA -- dok112 ------------------------------------------------------------------------ dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581 View this thread: http://www.excelforum.com/showthread...hreadid=532420 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want this macro to fire when I select "optAsc" and "optSig." I'm new
to this and know that I should do the "Select Case" or "If/Then" arguments, but I dont know how to code it. Do you have an "If" example to fire this one? And an example of how to "Then" it so I can do both ways with this one macro? (If you can't tell, I know enough to understand what needs to happen, just new enough that I can't get 'er done!) TIA |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Actually, my mistake. I didn't read the question fully. You can do If Then statement for the optionbuttons. Sub Test() If UserForm1.OptionButton1.value = True Then 'Response End If If UserForm1.OptionButton2.value = True Then 'Response End If End Sub Or a Select Case Statement can be used. Sub Test1() Select Case Value Case OptionButton1.Value = True 'Response Case OptionButton2.Value = True 'Response End Select End Sub dok112 Wrote: Is it dependant based on a checkbox, drop down, optionbutton? Sound like a Select Case or a If Then is necessary -- dok11 ----------------------------------------------------------------------- dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058 View this thread: http://www.excelforum.com/showthread.php?threadid=53242 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have 6 "responses." Do I need to do this for all six, or the first 5
and "Else" the last? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually I have another problem. I need two optionboxes selected: One
to determine Ascending or Descending for each of the 6 options. It looks like I need an "And" in there. (i.e., If optAsc = True AND optSig = True, then code above. If optDes = True AND optSig = True, the code above except xlDescending...etc. throughout 6 events, but only one fires, depending on the combination.) |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually I have another problem. I need two optionboxes selected: One
to determine Ascending or Descending for each of the 6 options. It looks like I need an "And" in there. (i.e., If optAsc = True AND optSig = True, then code above. If optDes = True AND optSig = True, the code above except xlDescending...etc. throughout 6 events, but only one fires, depending on the combination.) |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() So you have 6 options, of which there are 4 that are individual choices and 2 that are together? Or is it different? I'm a little confused. -- dok112 ------------------------------------------------------------------------ dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581 View this thread: http://www.excelforum.com/showthread...hreadid=532420 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Try this and tell me if this is what you are looking for... Sub Test() If optAsc.Value = True And optSig.Value = True Then ' Your code for optAsc and optSig = True End If If optDes.Value = True And optSig.Value = True Then ' Your code for optDes and optSig = True End if ' Add any more combinations of them that you need here. End Sub L Scholes Wrote: Actually I have another problem. I need two optionboxes selected: One to determine Ascending or Descending for each of the 6 options. It looks like I need an "And" in there. (i.e., If optAsc = True AN optSig = True, then code above. If optDes = True AND optSig = True, the code above except xlDescending...etc. throughout 6 events, but only one fires, depending on the combination. -- dok11 ----------------------------------------------------------------------- dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058 View this thread: http://www.excelforum.com/showthread.php?threadid=53242 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Option dependant upon entry!! | Excel Discussion (Misc queries) | |||
How to assing micro to a command button | Excel Discussion (Misc queries) | |||
keep source formatting is not an option in paste option button | Excel Discussion (Misc queries) | |||
Option button help | Excel Programming | |||
Option button | Excel Programming |