Good Afternoon,
I have been working on the VB below to pull a criteria through depending on the Score ("D33") I have managed to complete the below so it does this if only 1 is selected. I have been asked to do the same but if all is selected I need to pull all the data in for the specified dates. There are only 4 marks for the score as "Feels like I haven't done enough", "Feels like I have just done enough", "Feels Like I care" and "Extra Mile" Is there anyway to incorporate this into the VB below.
Many Thanks
Gavin
I have been working on the VB below to pull a criteria through depending on the Score ("D33") I have managed to complete the below so it does this if only 1 is selected. I have been asked to do the same but if all is selected I need to pull all the data in for the specified dates. There are only 4 marks for the score as "Feels like I haven't done enough", "Feels like I have just done enough", "Feels Like I care" and "Extra Mile" Is there anyway to incorporate this into the VB below.
Many Thanks
Gavin
Code:
Sub DoThatStuff()
Dim AgentName As Variant
Dim Assesor As Variant
Dim Score As Variant
Dim CriteriaName As Variant
Dim CriteriaScore As Variant
Dim Reason As Variant
Dim SubReason As Variant
Dim RaisedDate As Variant
Dim Startdate As Variant
Dim Stopdate As Variant
Dim x As Integer
Dim y As Integer
Sheets("SG").Select
Startdate = Range("D28").Value
Stopdate = Range("D29").Value
CriteriaName = Range("D31").Value
CriteriaScore = Range("D33").Value
If Startdate = "" Then
MsgBox "Please enter a date to search from"
Exit Sub
End If
If Stopdate = "" Then
MsgBox "Please enter a date to search to"
Exit Sub
End If
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x = 0
y = 0
Do
x = x + 1
Sheets("SG").Select
Range("C3").Select
AgentName = ActiveCell.Offset(x, 0).Value
Assesor = ActiveCell.Offset(x, 1).Value
Score = ActiveCell.Offset(x, 2).Value
Reason = ActiveCell.Offset(x, 5).Value
SubReason = ActiveCell.Offset(x, 6).Value
RaisedDate = ActiveCell.Offset(x, -1).Value
If AgentName = CriteriaName And Score = CriteriaScore And RaisedDate >= Startdate And RaisedDate <= Stopdate Then
y = y + 1
Sheets("SG").Select
Range("C35").Select
ActiveCell.Offset(y, -1).Value = RaisedDate
Range("C35").Select
ActiveCell.Offset(y, 0).Value = AgentName
Range("C35").Select
ActiveCell.Offset(y, 1).Value = Assesor
Range("C35").Select
ActiveCell.Offset(y, 4).Value = Score
Range("C35").Select
ActiveCell.Offset(y, 8).Value = Reason
Range("C35").Select
ActiveCell.Offset(y, 11).Value = SubReason
Sheets("SG").Select
Range("C3").Select
ActiveCell.Offset(x, 0).Select
Else
End If
ActiveCell.Offset(x, 0).Select
Loop Until AgentName = ""
Sheets("SGM").Select
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
End Sub
Last edited by a moderator: