quicksandNAV
New Member
- Joined
- Oct 30, 2024
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hello,
The following works correctly / as expected:
Form Controls / Group Box / Radio Button Method:
I'll include the whole block of code at the bottom. Basically, I'm looking to convert the above section to using Active X Controls so that it will be possible to adjust the size of the radio button and the button text.
That does successfully create the frame, but the attempt to set the caption to empty fails (cannot reference that way). I've tried recording Macro to catch; no code is shown for updating the caption text (entirely possible I'm not doing something right to catch it). Assuming the frame caption can be removed, it'd be good to add two radio buttons to the frame, and set / adjust their properties (font / size, default one of them to already clicked, etc), similar to the group boxes method that works.
Here is the whole code body:
The following works correctly / as expected:
Form Controls / Group Box / Radio Button Method:
VBA Code:
ActiveSheet.GroupBoxes.Add(Range("B" & (ThisRow + 1)).Left, Range("B" & (ThisRow + 1)).Top, Range("B" & (ThisRow + 1)).Width, Range("B" & (ThisRow + 1)).Height).Select
Selection.Characters.Text = ""
ActiveSheet.OptionButtons.Add(Range("B" & (ThisRow + 1)).Left + 1, Range("B" & (ThisRow + 1)).Top + 1, 72, 10).Select
Selection.Characters.Text = "No Issues Found"
Selection.Value = True
ActiveSheet.OptionButtons.Add(Range("B" & (ThisRow + 1)).Left + 1, Range("B" & (ThisRow + 1)).Top + 15, 72, 10).Select
Selection.Characters.Text = "Issues Found"
I'll include the whole block of code at the bottom. Basically, I'm looking to convert the above section to using Active X Controls so that it will be possible to adjust the size of the radio button and the button text.
VBA Code:
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Frame.1", Link:=False, DisplayAsIcon:=False, Left:=Range("B" & (ThisRow + 1)).Left, Top:=Range("B" & (ThisRow + 1)).Top, Width:=Range("B" & (ThisRow + 1)).Width, Height:=Range("B" & (ThisRow + 1)).Height).Select
'Selection.Caption = ""
That does successfully create the frame, but the attempt to set the caption to empty fails (cannot reference that way). I've tried recording Macro to catch; no code is shown for updating the caption text (entirely possible I'm not doing something right to catch it). Assuming the frame caption can be removed, it'd be good to add two radio buttons to the frame, and set / adjust their properties (font / size, default one of them to already clicked, etc), similar to the group boxes method that works.
Here is the whole code body:
VBA Code:
Public Sub Worksheet_Change(ByVal Target As Excel.Range)
'If Intersect(Target, Range(INDIRECT("C5:C"&ROWS(C:C))) Is Nothing Then Exit Sub
If Target.Column = 4 Then
ThisRow = Target.Row
If Target.Value <> "" Then
' We will be changing cells from an event, so disable events until done
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="password"
'Range("E" & ThisRow).Value = Now()
Range("F" & ThisRow).Value = Format(Now, "mm-dd-yy")
For Each cell In ActiveSheet.Range("A" & ThisRow & ":G" & ThisRow)
cell.Locked = True
Next cell
' Set default values for the next row
'Range("A" & (ThisRow + 1)).Value = "N/A"
'Range("B" & (ThisRow + 1)).CellControl.SetCheckbox
ActiveSheet.GroupBoxes.Add(Range("B" & (ThisRow + 1)).Left, Range("B" & (ThisRow + 1)).Top, Range("B" & (ThisRow + 1)).Width, Range("B" & (ThisRow + 1)).Height).Select
Selection.Characters.Text = ""
ActiveSheet.OptionButtons.Add(Range("B" & (ThisRow + 1)).Left + 1, Range("B" & (ThisRow + 1)).Top + 1, 72, 10).Select
Selection.Characters.Text = "No Issues Found"
Selection.Value = True
ActiveSheet.OptionButtons.Add(Range("B" & (ThisRow + 1)).Left + 1, Range("B" & (ThisRow + 1)).Top + 15, 72, 10).Select
Selection.Characters.Text = "Issues Found"
'With ActiveSheet.OLEObjects.Add(ClassType:="Forms.Frame.1", Link:=False, DisplayAsIcon:=False, Left:=Range("B" & (ThisRow + 1)).Left, Top:=Range("B" & (ThisRow + 1)).Top, Width:=Range("B" & (ThisRow + 1)).Width, Height:=Range("B" & (ThisRow + 1)).Height)
' Me.Caption = ""
'End With
Range("C" & (ThisRow + 1)).CellControl.SetCheckbox
' Re-protect the sheet
ActiveSheet.Protect Password:="password"
' Re-enable events
Application.EnableEvents = True
'Save the sheet
ThisWorkbook.Save
End If
End If
End Sub