Caveman1964
Board Regular
- Joined
- Dec 14, 2017
- Messages
- 127
- Office Version
- 2016
- Platform
- Windows
I have tried to resolve this through threads and videos but can't get it to work. My understanding of set and objects are not there yet.
I am getting the error "object variable or with variable not set when I click the combobox selection to put in cell.
Here is my code and would appreciate any help and guidence.
My task I am wanting to do is,
Click any one of 3 cells, a form pop up with a combobox with selections, just click the selection and it goes in the active cell and form disappears.
Private Sub ComboBox1_Change()
Dim selectedOption As String
selectedOption = ComboBox1.Value
' Get the active cell
Dim activeCell As Range
Set activeCell = activeCell
' Place the selected option into the active cell
activeCell.Value = selectedOption
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Apple"
.AddItem "Orange"
.AddItem "Pear"
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A4")) Is Nothing Then
' Show the user form
UserForm1.Show
End If
End Sub
I am getting the error "object variable or with variable not set when I click the combobox selection to put in cell.
Here is my code and would appreciate any help and guidence.
My task I am wanting to do is,
Click any one of 3 cells, a form pop up with a combobox with selections, just click the selection and it goes in the active cell and form disappears.
Private Sub ComboBox1_Change()
Dim selectedOption As String
selectedOption = ComboBox1.Value
' Get the active cell
Dim activeCell As Range
Set activeCell = activeCell
' Place the selected option into the active cell
activeCell.Value = selectedOption
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Apple"
.AddItem "Orange"
.AddItem "Pear"
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A4")) Is Nothing Then
' Show the user form
UserForm1.Show
End If
End Sub