Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Setting LinkedCell of individual OptionButton

I am creating multiple groupboxes with corresponding optionbuttons
inside it. I am having issues setting the LinkedCell property for
each radio button. For example, if I have 2 OptionButtons, I set the
LinkedCell of the first OptionButton to the right cell, when I add the second
OptionButton and set it's LinkedCell to the new .Address. The 1st OptionButton
is set to the new .Address.

Here's the code snippet when adding the OptionButton:


Public Sub InsertOptionButton(ByVal Target As Range, strGroupName As String)

Dim optBtn As OptionButton

Set WS = Application.ActiveWorkbook.Worksheets("Notes")

With Target

Set optBtn = WS.OptionButtons.Add _
(Top:=.Top + 4, Left:=.Offset(0, 0).Left + 40, Height:=.Height - 2.5, _
Width:=.Width / 2)

optBtn.Caption = ""
optBtn.Name = "opt" & .Address(0, 0)
optBtn.LinkedCell = .Address
optBtn.GroupBox.Name = strGroupName

End With

End sub


Thanks in advance,
Angelito
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 27,285
Default Setting LinkedCell of individual OptionButton

for optionbuttons from the forms toolbar, all optionbuttons in a group are
linked to the same cell. The cell then returns the sequence of the the
selected optionbutton.

So what you see is by design.

--
Regards,
Tom Ogilvy

"Angelito Cruz" wrote in message
...
I am creating multiple groupboxes with corresponding optionbuttons
inside it. I am having issues setting the LinkedCell property for
each radio button. For example, if I have 2 OptionButtons, I set the
LinkedCell of the first OptionButton to the right cell, when I add the

second
OptionButton and set it's LinkedCell to the new .Address. The 1st

OptionButton
is set to the new .Address.

Here's the code snippet when adding the OptionButton:


Public Sub InsertOptionButton(ByVal Target As Range, strGroupName As

String)

Dim optBtn As OptionButton

Set WS = Application.ActiveWorkbook.Worksheets("Notes")

With Target

Set optBtn = WS.OptionButtons.Add _
(Top:=.Top + 4, Left:=.Offset(0, 0).Left + 40, Height:=.Height - 2.5, _
Width:=.Width / 2)

optBtn.Caption = ""
optBtn.Name = "opt" & .Address(0, 0)
optBtn.LinkedCell = .Address
optBtn.GroupBox.Name = strGroupName

End With

End sub


Thanks in advance,
Angelito



  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Setting LinkedCell of individual OptionButton

Thanks Tom!

I figured out how to read the value of the option button on the cell
via this code:

Activesheet.optionbuttons("A3").value

Should I stay away from Optionbuttons from the forms toolbar and just
use the ActiveX equivalent? I am having the hardest time loading the
ActiveX OptionButton via VBA. I am sure it should be easier. Does
anyone have a code snippet I can look at? I will not be posting this
if I saw something that's close to what I am doing via the
Optionbutton from the forms toolbar.


Best Regards,
Angelito


"Tom Ogilvy" wrote in message ...
for optionbuttons from the forms toolbar, all optionbuttons in a group are
linked to the same cell. The cell then returns the sequence of the the
selected optionbutton.

So what you see is by design.

--
Regards,
Tom Ogilvy

"Angelito Cruz" wrote in message
...
I am creating multiple groupboxes with corresponding optionbuttons
inside it. I am having issues setting the LinkedCell property for
each radio button. For example, if I have 2 OptionButtons, I set the
LinkedCell of the first OptionButton to the right cell, when I add the

second
OptionButton and set it's LinkedCell to the new .Address. The 1st

OptionButton
is set to the new .Address.

Here's the code snippet when adding the OptionButton:


Public Sub InsertOptionButton(ByVal Target As Range, strGroupName As

String)

Dim optBtn As OptionButton

Set WS = Application.ActiveWorkbook.Worksheets("Notes")

With Target

Set optBtn = WS.OptionButtons.Add _
(Top:=.Top + 4, Left:=.Offset(0, 0).Left + 40, Height:=.Height - 2.5, _
Width:=.Width / 2)

optBtn.Caption = ""
optBtn.Name = "opt" & .Address(0, 0)
optBtn.LinkedCell = .Address
optBtn.GroupBox.Name = strGroupName

End With

End sub


Thanks in advance,
Angelito

  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 27,285
Default Setting LinkedCell of individual OptionButton

If you want to add an option button from either toolbar using code, just
turn on the macro recorder and do it manually. This will give you the
specific code you need. You can then generalize it.

Which to use would depend on the functionality you want to achieve.

--
Regards,
Tom Ogilvy

"Angelito Cruz" wrote in message
m...
Thanks Tom!

I figured out how to read the value of the option button on the cell
via this code:

Activesheet.optionbuttons("A3").value

Should I stay away from Optionbuttons from the forms toolbar and just
use the ActiveX equivalent? I am having the hardest time loading the
ActiveX OptionButton via VBA. I am sure it should be easier. Does
anyone have a code snippet I can look at? I will not be posting this
if I saw something that's close to what I am doing via the
Optionbutton from the forms toolbar.


Best Regards,
Angelito


"Tom Ogilvy" wrote in message

...
for optionbuttons from the forms toolbar, all optionbuttons in a group

are
linked to the same cell. The cell then returns the sequence of the the
selected optionbutton.

So what you see is by design.

--
Regards,
Tom Ogilvy

"Angelito Cruz" wrote in message
...
I am creating multiple groupboxes with corresponding optionbuttons
inside it. I am having issues setting the LinkedCell property for
each radio button. For example, if I have 2 OptionButtons, I set the
LinkedCell of the first OptionButton to the right cell, when I add the

second
OptionButton and set it's LinkedCell to the new .Address. The 1st

OptionButton
is set to the new .Address.

Here's the code snippet when adding the OptionButton:


Public Sub InsertOptionButton(ByVal Target As Range, strGroupName As

String)

Dim optBtn As OptionButton

Set WS = Application.ActiveWorkbook.Worksheets("Notes")

With Target

Set optBtn = WS.OptionButtons.Add _
(Top:=.Top + 4, Left:=.Offset(0, 0).Left + 40, Height:=.Height -

2.5, _
Width:=.Width / 2)

optBtn.Caption = ""
optBtn.Name = "opt" & .Address(0, 0)
optBtn.LinkedCell = .Address
optBtn.GroupBox.Name = strGroupName

End With

End sub


Thanks in advance,
Angelito



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
ActiveX Combobox and LinkedCell aqualibra Excel Worksheet Functions 2 August 21st 08 08:36 PM
Combo Box "LinkedCell" option Patty via OfficeKB.com Excel Discussion (Misc queries) 0 August 2nd 05 10:01 PM
Linkedcell protection problem Karin New Users to Excel 2 June 24th 05 12:03 AM
LinkedCell Update does not always respond Jeroen Kluytmans Excel Programming 4 April 16th 04 08:58 AM
Linkedcell Problems... cornishbloke[_25_] Excel Programming 3 January 21st 04 02:45 PM


All times are GMT +1. The time now is 06:10 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"