Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default 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
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
Reset button code for Radio Buttons [email protected] Excel Discussion (Misc queries) 6 August 25th 12 03:09 PM
Help with radio button Diana Excel Discussion (Misc queries) 1 July 17th 06 09:29 PM
"RADIO BUTTON" Ian Shere Excel Discussion (Misc queries) 1 July 4th 05 10:59 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True Mcasteel Excel Worksheet Functions 2 October 29th 04 07:06 PM


All times are GMT +1. The time now is 11:48 PM.

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

About Us

"It's about Microsoft Excel"