I have code for a command button click event that keeps throwing error 91. When I step through the code it throws the error right after the 'Set findvalue' code executes. See code snippet below. I can't figure it out upon inspection of the code itself.
'findvalue' is dimensioned as a range object. 'DataSH' is the worksheet where the master data table exists beginning with the column for Record ID (column B). The user form elements are set to their respective columns in the data table on DataSH.
Private Sub cmdEdit_Click()
'declare the variables
Dim findvalue As Range
Dim cNum As Integer
Dim DataSH As Worksheet
'error handling
On Error GoTo errHandler:
'hold in memory and stop screen flicker
Application.ScreenUpdating = False
Set DataSH = Sheet1
The click event sub routine that this snippet is taken from is setup to update the appropriate column data on the row for the selected Record ID (row number identifier) in DataSH based on the value in those UF elements (i.e. changed or deleted values). The point is to update the master data table on DataSH with any changes made in the UF elements (text boxes and combo boxes).
Set findvalue = DataSH.Range("B:B"). _
Find(What:=Me.tbRecID.Value, LookIn:=xlValues, LookAt:=xlWhole)
'update the values
findvalue = tbRecID.Value
findvalue.Offset(0, 1) = tbRecDate.Value
findvalue.Offset(0, 2) = cmbRecLoc.Value
findvalue.Offset(0, 3) = cmbRecCust.Value
findvalue.Offset(0, 4) = tbRecAmt.Value
findvalue.Offset(0, 5) = cmbRecComm.Value
findvalue.Offset(0, 6) = cmbRecPrin.Value
findvalue.Offset(0, 7) = tbRecTerr.Value
findvalue.Offset(0, 8) = tbRecRep.Value