View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pgarcia pgarcia is offline
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