Damocles2021
New Member
- Joined
- Mar 6, 2021
- Messages
- 4
- Office Version
- 365
- 2016
- Platform
- Windows
Hi All
I'm currently wanting to populate a sheet chosen from a combobox on Userform1
I have 7 worksheets named Room 1, Room 2 etc, all the sheets have Appointment times in Column A2 - A28 and Dates across the rows B2 - AF1 (31 days)
The userform has 3 comboboxes, (txtRoom, cboName, cboTime) and 1 Textbox, (txtDate). 1 command button, cmdSave
I'm trying to adapt some code that @mumps provided in an early query, (Thank you very much, works like a charm! )
What I want to achieve is User selects a Room, Time and name from dropdowns and inputs the date and clicks Save, which would transfer the data into the selected ROOM sheet
What I have so far....
I have played with the code in all sorts of different ways, been hit with the excel vba object variable or with block variable not set,
When I go through the 'debug' and hover over the code where data should be it shows the correct entries in the form controls, all except the line above.
The thing is I know I'm missing something thats probably staring me in the face, or gone through my mind, I believe (could be wrong)its the way Im referencing that line of code that shows the error. Any help appreciated, although I would like to try and solve it myself (best way to learn ) but been at it for ages so now to hand over to the experts!
Thanks in advance
I'm currently wanting to populate a sheet chosen from a combobox on Userform1
I have 7 worksheets named Room 1, Room 2 etc, all the sheets have Appointment times in Column A2 - A28 and Dates across the rows B2 - AF1 (31 days)
The userform has 3 comboboxes, (txtRoom, cboName, cboTime) and 1 Textbox, (txtDate). 1 command button, cmdSave
I'm trying to adapt some code that @mumps provided in an early query, (Thank you very much, works like a charm! )
What I want to achieve is User selects a Room, Time and name from dropdowns and inputs the date and clicks Save, which would transfer the data into the selected ROOM sheet
What I have so far....
VBA Code:
Private Sub cmdSave_Click()
Dim aptTime As Range, aptDate As Range
Myfrm = UserForm1.cboRoom.Value
With Myfrm
Set aptDate = Range("A:A").Find(txtDate.Value, LookIn:=xlValues, lookat:=xlWhole)
Set aptTime = Rows(1).Find(cboTime.Value, LookIn:=xlValues, lookat:=xlWhole)
.Cells(aptDate.Row, aptTime.Column) = cboName.Value
End With
End Sub
I have played with the code in all sorts of different ways, been hit with the excel vba object variable or with block variable not set,
VBA Code:
.Cells(aptDate.Row, aptTime.Column) = cboName.Value
When I go through the 'debug' and hover over the code where data should be it shows the correct entries in the form controls, all except the line above.
The thing is I know I'm missing something thats probably staring me in the face, or gone through my mind, I believe (could be wrong)its the way Im referencing that line of code that shows the error. Any help appreciated, although I would like to try and solve it myself (best way to learn ) but been at it for ages so now to hand over to the experts!
Thanks in advance