Multiple Selection to search

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
754
Office Version
  1. 365
Platform
  1. Windows
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


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:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,203,508
Messages
6,055,815
Members
444,826
Latest member
aggerdanny

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top