Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
radio button with VB code
Hello all,
Im needing the following: 4 radio buttons, Default, GTD, ECO, BOTH. When running a VB code, I need to code to look at what button has been selected and call another VB code or in the case of Default it keeps running the code with out interruption. So, VB code is running, then it looks at the radio buttons, see that GTD is select and then calls another VB code, then it continues on with the rest of the code when the other code is finished. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
radio button with VB code
assuming you have grabbed option buttons from the control toolbox code like
this might do it... Sub test() If OptionButton1 Then MsgBox OptionButton1.Name ElseIf OptionButton2 Then MsgBox OptionButton2.Name ElseIf OptionButton3 Then MsgBox OptionButton3.Name ElseIf OptionButton4 Then MsgBox OptionButton1.Name Else MsgBox "none" End If End Sub -- HTH... Jim Thomlinson "pgarcia" wrote: Hello all, Im needing the following: 4 radio buttons, Default, GTD, ECO, BOTH. When running a VB code, I need to code to look at what button has been selected and call another VB code or in the case of Default it keeps running the code with out interruption. So, VB code is running, then it looks at the radio buttons, see that GTD is select and then calls another VB code, then it continues on with the rest of the code when the other code is finished. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
radio button with VB code
Thanks, this is what I did and what I need it for, but it did not work like I
want it to. It does not bring up the "Call" VB codes. Could you take a look at it for me and point out what I'm doing wrong? Thanks Sheets("INPUT_A").Select If OptionButton2 Then Call AR_GTD ElseIf OptionButton3 Then Call AR_Both ElseIf OptionButton4 Then Call AR_ECO End If It should run one the following: Sub AR_GTD() Sheets("AR").Select Rows("17:20,35:38,53:56,78:81,102:105,140:147,160: 167,181:187").Select Selection.Delete Shift:=xlUp Range("A1").Select End Sub Sub AR_ECO() Sheets("AR").Select Range("7:8,25:26,43:44,68:69,92:93,136:137,156:157 ,176:177").Select Selection.Delete Shift:=xlUp Range("A1").Select End Sub Sub AR_Both() Sheets("AR").Select Range( "7:8,17:20,25:26,35:38,43:44,53:56,68:69,78:81,92: 93,102:105,136:137,140:147,160:163,164:167,176:177 ,180:187,156:157" _ ).Select Selection.Delete Shift:=xlUp Range("A1").Select End Sub And this is what the whole code is: Sub Copy_Paste_AR() ' Application.ScreenUpdating = False Sheets("AR").Visible = True Dim MyPath As String Dim MyFileName As String Sheets("AR").Select Range("H1:H187", Range("H1:H187").End(xlDown)).Copy Range("H1").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Columns("A:G").Delete Shift:=xlToLeft Sheets("INPUT_A").Select If OptionButton2 Then Call AR_GTD ElseIf OptionButton3 Then Call AR_Both ElseIf OptionButton4 Then Call AR_ECO End If Sheets("AR").Select MyPath = "S:\SUPPORT\CADTAR\CMS\!Exported_Text_Files!\" MyFileName = "d" & Sheets("INPUT_A").Range("C8").Value & "ar" ActiveWorkbook.SaveAs Filename:=MyPath & MyFileName, _ FileFormat:=xlText, CreateBackup:=False Sheets("INPUT_A").Select MsgBox ("AR file has been created at:" & vbLf & "S:\SUPPORT\CADTAR\CMS\!Exported_Text_Files!\" ) End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Reset button code for Radio Buttons | Excel Discussion (Misc queries) | |||
Help with radio button | Excel Discussion (Misc queries) | |||
"RADIO BUTTON" | Excel Discussion (Misc queries) | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True | Excel Worksheet Functions |