This may be easy to do but my minds on overtime today.
Heres the code I have so far:
Where I have the heading "Get Row End Number" I want to loop through column A of the range 'Report' that is passed as a parameter starting with the row number that is stored in 'StartRowIndex'. I want the loop to stop when the first part of the cells value = "Agent"
And then store the cells row number in EndRowIndex.
The only thing im not sure about is looping through column A in a range that has already been specified.
Heres the code I have so far:
Code:
'Look Up Name, Find And Return Total Of Selected Option'
Public Function GetShrinkage(Name As String, Activity As String, Report As Range) As Date
'-----------------'
'Declare Variables'
'-----------------'
Dim StartRowIndex As Long 'To Store The First Row Number'
Dim EndRowIndex As Long 'To Store The Last Row Number'
Dim ReturnValue As Date 'To Hold The Running Total'
Dim TestRange As Range 'To Hold The Resulting Range Of The Search'
'-------------'
'Set Variables'
'-------------'
ReturnValue = TimeValue("00:00:00") 'Set Starting Value So 00:00:00 Is Returned For No Match'
StartRowIndex = 0 'Set Initial Value'
EndRowIndex = 0 'Set Initial Value'
'--------------------'
'Get Start Row Number'
'--------------------'
Set TestRange = Report.Find(Name) 'Look For Name And Store Resulting Range'
'Test If Name Found'
If TestRange Is Nothing Then
GetShrinkage = CVErr(xlErrNA)
Exit Sub
End If
'Result Found/Store Start Row Index'
StartRowIndex = TestRange.Row
'--------------------'
'Get End Row Number'
'--------------------'
Dim LoopCounter As Long 'To Loop Through Rows'
LoopCounter = StartRowIndex 'Set Start Row Value'
End Function
Where I have the heading "Get Row End Number" I want to loop through column A of the range 'Report' that is passed as a parameter starting with the row number that is stored in 'StartRowIndex'. I want the loop to stop when the first part of the cells value = "Agent"
Code:
Left(Cell.Text, 5) = "Agent"
And then store the cells row number in EndRowIndex.
The only thing im not sure about is looping through column A in a range that has already been specified.