M
Mike Archer
Hello. I pasted a macro below. An error occurs when the line for Cells.Find
is executed. It is error 91 (object or variable not found). I have
experiemented with the "What" criteria. If the variable string PPMDate is
more than 1 character, the error occurs. If is 1 charter or empty, the error
does not occur. Could someone clue me in on this?
Thanks in advance,
Mike
Private Sub CopyData()
Dim PPMData As String
Dim PPMDate As String
' Get the Escape number
Selection.Offset(0, 9).Select
' If the cell is blank then force to zero
PPMData = ActiveCell.Value
If Not IsNumeric(PPMData) Then PPMData = "0"
Workbooks(myWorkbookName).Activate
Sheets("PPM_Data").Select
PPMDate = Replace(ReadWorkbookName, ".xls", "")
PPMDate = Format(PPMDate, "m/d/yyyy")
Range("A1").Select
'Error 91 Occurs here:
Cells.Find(What:=PPMDate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Selection.Offset(0, 5).Select
ActiveCell.Value = PPMData
' Now get the Catch number
Workbooks(ReadWorkbookName).Activate
Selection.Offset(-1, 0).Select
' If the cell is blank then force to zero
PPMData = ActiveCell.Value
If Not IsNumeric(PPMData) Then PPMData = "0"
Workbooks(myWorkbookName).Activate
Selection.Offset(0, -1).Select
ActiveCell.Value = PPMData
End Sub
is executed. It is error 91 (object or variable not found). I have
experiemented with the "What" criteria. If the variable string PPMDate is
more than 1 character, the error occurs. If is 1 charter or empty, the error
does not occur. Could someone clue me in on this?
Thanks in advance,
Mike
Private Sub CopyData()
Dim PPMData As String
Dim PPMDate As String
' Get the Escape number
Selection.Offset(0, 9).Select
' If the cell is blank then force to zero
PPMData = ActiveCell.Value
If Not IsNumeric(PPMData) Then PPMData = "0"
Workbooks(myWorkbookName).Activate
Sheets("PPM_Data").Select
PPMDate = Replace(ReadWorkbookName, ".xls", "")
PPMDate = Format(PPMDate, "m/d/yyyy")
Range("A1").Select
'Error 91 Occurs here:
Cells.Find(What:=PPMDate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Selection.Offset(0, 5).Select
ActiveCell.Value = PPMData
' Now get the Catch number
Workbooks(ReadWorkbookName).Activate
Selection.Offset(-1, 0).Select
' If the cell is blank then force to zero
PPMData = ActiveCell.Value
If Not IsNumeric(PPMData) Then PPMData = "0"
Workbooks(myWorkbookName).Activate
Selection.Offset(0, -1).Select
ActiveCell.Value = PPMData
End Sub