GalaxyFlip4
New Member
- Joined
- Oct 16, 2022
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi all,
I am attempting to create a checkbox on an Excel worksheet when a command button is pressed and clear the checkbox caption.
I get an error message: "Compile Error - Invalid or unqualified reference" and the .Left is highlighted in this line: sh.CheckBoxes.Add(.Left + 1, .Top + 15, .Width - 1, .Height - 1).Select
Below is the code:
**********************************************
Private Sub CommandButton1_Click()
Dim lastRow As Double
Dim sh As Worksheet
Set sh = Sheets("data")
lastRow = sh.Range("A" & Rows.Count).End(xlUp).Row + 1
With sh.Range("E" & lastRow)
End With
sh.CheckBoxes.Add(.Left + 1, .Top + 15, .Width - 1, .Height - 1).Select
With Selection
.Caption = ""
'ChkBox.Caption = ""
End With
End Sub
*********************************************
Any ideas on how to fix?
Thank you all very much and be well.
Dion
<>
I am attempting to create a checkbox on an Excel worksheet when a command button is pressed and clear the checkbox caption.
I get an error message: "Compile Error - Invalid or unqualified reference" and the .Left is highlighted in this line: sh.CheckBoxes.Add(.Left + 1, .Top + 15, .Width - 1, .Height - 1).Select
Below is the code:
**********************************************
Private Sub CommandButton1_Click()
Dim lastRow As Double
Dim sh As Worksheet
Set sh = Sheets("data")
lastRow = sh.Range("A" & Rows.Count).End(xlUp).Row + 1
With sh.Range("E" & lastRow)
End With
sh.CheckBoxes.Add(.Left + 1, .Top + 15, .Width - 1, .Height - 1).Select
With Selection
.Caption = ""
'ChkBox.Caption = ""
End With
End Sub
*********************************************
Any ideas on how to fix?
Thank you all very much and be well.
Dion
<>