All,
I am getting an Application-defined or object defined error in the last line of my code below.
Sub Compare()
'Calls workOnSheet. This opens up CostPoint file and formats for use.
Call workOnSheet
If StopFlag Then
Exit Sub
End If
'===========================================================================================================
'Get hours off of Timesheet Daily Detail Inquiry for the first Person.
Set gplainId = ActiveSheet.Cells(3, 2) 'Find the employee Id of first person
Set glastName = ActiveSheet.Cells(3, 3) 'Find the employee id of the first person
Set gboldId = ActiveSheet.Cells(4, 2) 'Find the employee Id of the first person as bold
With Workbooks(DEFName).Sheets("Page1_2").Range("A:A")
Set ge = .Find(gplainId, LookIn:=xlValues)
If IsEmpty(Worksheets("PATH").Cells(2, 2)) Then
MsgBox "Requested Project Does Not Exist", vbExclamation, "No Such Project Code"
Exit Sub
Else:
On Error Resume Next
gbeginRow = Str(ge.Row)
If Err.Number <> 0 Then
MsgBox "Requested Project Does Not Exist", vbExclamation, "No Such Project Code"
Exit Sub
End If
On Error GoTo 0
End If
End With
Debug.Print gbeginRow
With Workbooks(DEFName).Sheets("Page1_2").Range("B:B")
Set gcell1 = Cells(gbeginRow, 2)
Set gd = .Find(glastName, After:=gcell1, LookIn:=xlValues)
gstartRow = Int(gd.Row)
End With
Debug.Print gstartRow
With Workbooks(DEFName).Sheets("Page1_2").Range("A:A")
Set gcell2 = Cells(gstartRow, 1)
Set gc = .Find(gboldId, After:=gcell2, LookIn:=xlValues)
gendRow = Int(gc.Row)
End With
Debug.Print gendRow
'****** GOT TO HERE********** Want to get the hours somehow and put in checker.
' You need to get a range for the employee id or name along with the charge code. You don't have this at the moment.
gsRng1 = Range(Cells(gstartRow, 2), Cells(gendRow, 2)).Address(False, False) ' Get the name with this one.
gsRng2 = Range(Cells(gstartRow, 18), Cells(gendRow, 18)).Address(False, False) ' Get the hours with this one.
gsRng3 = Range(Cells(gstartRow, 13), Cells(gendRow, 13)).Address(False, False) ' Get the charge codes with this one
gsRef = "[" & DEFName & "]Page1_2"
For gtheRow = 3 To 20
ggetHours = "=SUMIF(" & gsRef & gsRng3 & ", """ & Cells(gtheRow, 5).Value & """, " & gsRef & gsRng2 & ")"
Debug.Print ggetHours
'Range("E5") = "GOT HERE"
Cells(gtheRow, "F").Formula = ggetHours
End Sub
The code 'Cells(gtheRow, "F").Formula = ggetHours is throwing the error. Please help if you know what I am doing wrong. I have basically the same type of code in another workbook with a slight twist on it, and it does not throw an error out at me.
Thank you -- SEOT
Bookmarks