Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Radio Buttons


Hi please bear with me on this as I'm new at this!!
I'm trying to work out how to use Radio Buttons with Command Buttons?
I have 4 buttons (A,B,C,D, each for a different worksheet ) and
Command Buttons (1 to 9 with Names),what code do I need if I click on
button (Name) to go to the selected radio button??
Any help appreciated

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Radio Buttons

Hello GrahamD,

Assume you have 4 options button(radio buttons) named a to d.
To make a radio button selected, you need to specity the Worksheet name and
the control name like this.
Here is acode for CommandButtons.

Private Sub CommandButton1_Click()
Sheet1.a.Value = True
End Sub

Private Sub CommandButton2_Click()
Sheet2.b.Value = True
End Sub


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

"GrahamD" wrote in message
...

Hi please bear with me on this as I'm new at this!!
I'm trying to work out how to use Radio Buttons with Command Buttons?
I have 4 buttons (A,B,C,D, each for a different worksheet ) and 9
Command Buttons (1 to 9 with Names),what code do I need if I click on a
button (Name) to go to the selected radio button??
Any help appreciated.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Radio Buttons


Thanks for the quick reply Colo.
However, I keep getting a "compile error",
"Method or data member not found", with the (.a) in the cod
highlighted?

Confused..

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Radio Buttons

OK Graham, the code below makes a sample workbook with VBA code.
Place this code in the standard module and run, then a sample worksheet will
be made.
Please have a look at code and objects names.
Hope this helps.

Sub MakeSampleWbk()
Dim wbSample As Workbook
Dim lngShINW As Long
Dim arrNames As Variant
Dim strCode As String
Dim i As Long
arrNames = Array("a", "b", "c", "d")
lngShINW = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 4
Set wbSample = Workbooks.Add '//Add Worksheet
Application.SheetsInNewWorkbook = lngShINW
For i = 1 To 4 '//Add Objects and Make code for CommandButton
With wbSample
With
..Sheets(i).OLEObjects.Add(ClassType:="Forms.Optio nButton.1", _
Left:=50, Top:=50, Width:=100,
Height:=20)
.Name = arrNames(i - 1)
.Object.Caption = "This name is " & arrNames(i - 1)
End With
.Sheets(1).OLEObjects.Add(ClassType:="Forms.Comman dButton.1", _
Left:=150, Top:=15 + 30 * i,
Width:=120, Height:=30).Name _
= "CommandButton" & i
strCode = strCode & _
"Private Sub CommandButton" & i & "_Click()" & vbLf &
vbTab & _
"Sheet" & i & "." & "Select" & vbLf & vbTab & _
"Sheet" & i & "." & arrNames(i - 1) & ".Value = True"
& vbLf & _
"End Sub" & vbLf & vbLf
End With
Next

With wbSample.VBProject.VBComponents.Item("Sheet1").Cod eModule
.DeleteLines 1, .CountOfLines '//Delete Codes already
wrriten
.InsertLines 1, strCode '// Write Code
End With
End Sub


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
"GrahamD" wrote in message
...

Thanks for the quick reply Colo.
However, I keep getting a "compile error",
"Method or data member not found", with the (.a) in the code
highlighted?

Confused...


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Radio Buttons


Colo,
Thanks for your time and trouble, but I must be dumb as.
All I kept getting was "Compile Errors"
I did however end up working out my problem, although it took som
time.
This is what I ended up with...

Private Sub cmdButton1_Click()
If optButton1.Value = True Then
Application.Goto Reference:=Worksheets("Sheet1").Range("A1"), _
Scroll:=True
End If
If optButton2.Value = True Then
Application.Goto Reference:=Worksheets("Sheet2").Range("A1"), _
Scroll:=True
End If
If optButton3.Value = True Then
Application.Goto Reference:=Worksheets("Sheet3").Range("A1"), _
Scroll:=True
End If
If optButton4.Value = True Then
Application.Goto Reference:=Worksheets("Sheet4").Range("A1"), _
Scroll:=True
End If

End Sub
........................................

Private Sub optButton1_Click()

End Sub
........................................
Private Sub optButton2_Click()

End Sub
........................................

Private Sub optButton3_Click()

End Sub
........................................

Private Sub optButton4_Click()

End Sub
.......................................

CHEERS
GRAHA

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Radio Buttons

Hello GRAHAM, on my Excel your code works.
Please re-check if the object name is correct or not.

You can see a sample file at

http://www.interq.or.jp/sun/puremis/...oft/Sample.XLS

Private Sub cmdButton1_Click()
Dim i As Long
For i = 1 To 4
If Me.OLEObjects("optButton" & i).Object.Value Then
Application.Goto Sheets("Sheet" & i).Range("A1"), True
Exit For
End If
Next
End Sub


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


"GrahamD" wrote in message
...

Colo,
Thanks for your time and trouble, but I must be dumb as.
All I kept getting was "Compile Errors"
I did however end up working out my problem, although it took some
time.
This is what I ended up with...

Private Sub cmdButton1_Click()
If optButton1.Value = True Then
Application.Goto Reference:=Worksheets("Sheet1").Range("A1"), _
Scroll:=True
End If
If optButton2.Value = True Then
Application.Goto Reference:=Worksheets("Sheet2").Range("A1"), _
Scroll:=True
End If
If optButton3.Value = True Then
Application.Goto Reference:=Worksheets("Sheet3").Range("A1"), _
Scroll:=True
End If
If optButton4.Value = True Then
Application.Goto Reference:=Worksheets("Sheet4").Range("A1"), _
Scroll:=True
End If

End Sub
.......................................

Private Sub optButton1_Click()

End Sub
.......................................
Private Sub optButton2_Click()

End Sub
.......................................

Private Sub optButton3_Click()

End Sub
.......................................

Private Sub optButton4_Click()

End Sub
......................................

CHEERS
GRAHAM


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements

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
Radio buttons Pawan Excel Discussion (Misc queries) 0 November 18th 08 01:24 PM
Option Buttons/Radio Buttons John Calder New Users to Excel 7 May 16th 08 03:51 AM
radio Buttons Kev Excel Discussion (Misc queries) 1 June 18th 07 07:26 PM
Radio Buttons Bethie at CLG Excel Worksheet Functions 6 October 31st 05 09:08 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 06:52 AM.

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"