I have an Excel file with one sheet called Master.
I have a button to delete a value from the database. This is what I have written that's relevant:
Sub delete_this()
On Error GoTo ErrorCatch
simple = Sheets("Master")
.........
ErrorCatch
MsgBox(Err.Description)
End Sub
It fails immediately when I use Sheets, saying "Application-defined or object-defined error." However I'm using other code that I know works as a reference and they called this no problem (though their file had multiple sheets).
Also in general I'm new to VBA and find it pretty unintuitive with its error messages, and finding out variable values. So any advice there would also be appreciated.
Dim simple as Worksheet-Set simple = worksheets("Master")you forgot theSetSheetsis an object, not a function.Sheetsis a property of theGlobalhidden module, which returns an object of typeSheetsoffActiveWorkbook. So depending on how you look at it, "Sheets" is either a class or a property, but not an object.