I am using the below code. If I use it when the report sheet is selected it runs fine but if I run it when the summary sheet is selected I get the type mismatch error.
Can anyone see something im missing?
Can anyone see something im missing?
Code:
Public Sub GetData()
Call GetRanges
Dim X As Integer
Dim Y As Integer
X = 0
Y = 0
For X = 1 To UBound(AgentData)
For Y = AgentData(X).RowStartIndex To AgentData(X).RowEndIndex
If Worksheets("Report").Range("D" & Y).Text <> vbNullString Then
Select Case Worksheets("Report").Range("D" & Y).Text
Dim Rng As Range
Case "Not_Ready_Default_Reason_Code"
Set Rng = Range("SummaryRange").Find(AgentData(X).Name).Offset(0, 1)
Rng.Value = TimeValue(Rng.Text) + TimeValue(Range("D" & Y).Offset(0, 2).Text)
Case "Other Admin"
Set Rng = Range("SummaryRange").Find(AgentData(X).Name).Offset(0, 2)
Rng.Value = TimeValue(Rng.Text) + TimeValue(Range("D" & Y).Offset(0, 2).Text)
Case "Personal"
Set Rng = Range("SummaryRange").Find(AgentData(X).Name).Offset(0, 3)
Rng.Value = TimeValue(Rng.Text) + TimeValue(Range("D" & Y).Offset(0, 2).Text)
End Select
End If
Next Y
Next X