Hello,
I'm trying to create a userform that will input data into a sheet however when ran it gives me a Method Value Of Object Range Failed error and then completely crashes Excel.
The sheet i'm trying to input in is a table so i'm not sure if that's what's throwing it out as if I change the sheet reference to a blank sheet it works perfectly fine.
Here's the code:
It gets stuck on the first .Cells(newRow, 1).value line.
Any suggestions?
Thanks
I'm trying to create a userform that will input data into a sheet however when ran it gives me a Method Value Of Object Range Failed error and then completely crashes Excel.
The sheet i'm trying to input in is a table so i'm not sure if that's what's throwing it out as if I change the sheet reference to a blank sheet it works perfectly fine.
Here's the code:
Code:
Private Sub WriteDataToSheet()
Dim newRow As Long
With shData
newRow = .Cells(.Rows.Count, 1).End(xlUp).row + 1
.Cells(newRow, 1).Value = txtID.Value
.Cells(newRow, 2).Value = cboCategory.Value
.Cells(newRow, 3).Value = cboSubcategory.Value
.Cells(newRow, 4).Value = txtCost.Value
.Cells(newRow, 5).Value = txtDate.Value
.Cells(newRow, 6).Value = cboMonth.Value
End With
End Sub
It gets stuck on the first .Cells(newRow, 1).value line.
Any suggestions?
Thanks