Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default option button dependant micro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default option button dependant micro


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default option button dependant micro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default option button dependant micro


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default option button dependant micro

I have 6 "responses." Do I need to do this for all six, or the first 5
and "Else" the last?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default option button dependant micro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default option button dependant micro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default option button dependant micro


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default option button dependant micro


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option dependant upon entry!! Baffled Excel Discussion (Misc queries) 2 September 29th 08 10:05 PM
How to assing micro to a command button Qazi Ahmad Excel Discussion (Misc queries) 1 April 9th 07 06:38 AM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM
Option button help justaguyfromky Excel Programming 1 September 5th 05 10:17 PM
Option button Jennifer Excel Programming 3 April 15th 05 10:28 PM


All times are GMT +1. The time now is 02:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"