Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Dynamically Create and ID OptionButtons, then insert Row; Loop

For anyone who is interested, I found a solution he
http://www.ozgrid.com/forum/showthread.php?t=51508


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ryguy7272" wrote:

Im making a little progress here, but not as much as Id like. I came up
with this idea for grouping the OptionButtons:
Dim sh As Worksheet
Dim oleObj As OLEObject

For Each sh In Worksheets

i = 1
For Each oleObj In sh.OLEObjects
If TypeOf oleObj.Object Is MSforms.OptionButton Then
oleObj.Object.GroupName = sh.Name & i
End If
i = i + 1
Next

Next
The scenario is that there will be 2 OptionButtons per row, from row 12 to
row whatever. Maybe I will go to row 20, or 30, not sure; thats why I want
to create these OptionButtons at runtime and insert rows (to push the stuff
below down by one row each time). I still havent come up with working-code
ot do this. Also, how would I group the OptionButtons so that each row has
the same €˜GroupName. It doesnt matter what the name is; could be
Worksheet1 for the two OptionButtons on row 12 and Worksheet2 for the two
OptionButtons on row 13. The GroupName is pretty darn important for the
OptionButtons to work. Does it make sense?

Im open to suggestions for this task. Perhaps there is a better way to do
this...


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ryguy7272" wrote:

This is a bit complex, so let me take a moment to explain. Im trying to
open a €˜template and connect the code to a button so a user can click it and
put a €˜1 in cell Z16, then put an OptionButton in A16 and another
OptionButton in B16, then assign an identifier to these OptionButtons (a name
or a value to identify these objects). Then a row is inserted at row 17.
Then if the user clicks the button again, a 2 goes into Z17, and an
OptionButton goes into A16 and another OptionButton goes into B17, these are
identified (somehow) and a row is inserted at row 18. If the user clicks the
button again, a 3 goes into Z18, and . . . so on and so forth.

Heres the code I have now.
Private Sub CommandButton3_Click()
Dim optBtn As OptionButtons

Range("Z16").Select
ActiveCell.Value = 1

i = 5
For i = 1 To j
ActiveSheet.OptionButtons.Add ActiveCell.Offset(0, -26).Left,
ActiveCell.Top, ActiveCell.Width, ActiveCell.Height
ActiveSheet.OptionButtons.Add ActiveCell.Offset(0, -25).Left,
ActiveCell.Top, ActiveCell.Width, ActiveCell.Height
ActiveCell.Selection.EntireRow.Insert

Set WS = Application.ActiveWorkbook.Worksheets("Worksheet")
With Targe
optBtn.Caption = ""
optBtn.GroupBox.Name = strGroupName & j
End With

Next i

End Sub

What am I doing wrong?

Thanks!
Ryan

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

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
Create loop to insert two rows after every row of data [email protected] Excel Programming 2 August 17th 07 02:09 AM
Dynamically Insert Rows Matt[_48_] Excel Programming 0 May 23rd 07 09:19 PM
Dynamically setting Dimensions in a VBA loop havocdragon Excel Programming 4 September 13th 06 08:34 AM
Loop with activeX optionbuttons. Jan Vente Excel Programming 3 February 8th 06 03:39 PM
Dynamically insert a picture. Cherokee84 Excel Programming 1 March 19th 05 04:07 PM


All times are GMT +1. The time now is 01:55 AM.

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

About Us

"It's about Microsoft Excel"