Hi, I am currently learning how use VBA and have run into a problem.
At the moment I am trying to basically make a report that will query a set of date I have in one sheet and return or copy the results into the other spread sheet.
what i have done so far looks roughly like this:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> </o>
My problem is this method will return all the data that has the any of the selected data in it within the specified date range, what i would like to have it do is only return the data if it has all the relevant data in it, so using “And” but only if the cells (E.g. C4, C6, E4, E6 ETC) have data in them. <o></o>
è Basically i want to be able to both board and narrow queries using this macro <o></o>
I am sure there is a very easy way to do this but I am unsure of how to do it ! <o></o>
<o> </o>
Any help would be very much appreciated <o></o>
<o> - </o>Sov <o></o>
At the moment I am trying to basically make a report that will query a set of date I have in one sheet and return or copy the results into the other spread sheet.
what i have done so far looks roughly like this:
Code:
Private Sub Button2_Click()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Iteration = Range("A2").Value
Range("B10").Select
Range("B10:G50").ClearContents
Range("C4") = StartDate.Text
Range("C6") = EndDate.Text
Range("E4") = Project.Text
Range("E6") = Status.Text
Range("G4") = Team.Text
Range("G6") = Person.Text
Sheets("Database").Select
Range("B5").Select
For Count = 0 To Iteration
If ActiveCell.Value >= StartDate And ActiveCell.Value <= EndDate And ActiveCell.Offset(0, 1).Value = Project Or ActiveCell.Offset(0, 3).Value = Status Or ActiveCell.Offset(0, 4).Value = Team Or ActiveCell.Offset(0, 5).Value = Person Then
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 6)).Copy
Sheets("Summary").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End Sub
My problem is this method will return all the data that has the any of the selected data in it within the specified date range, what i would like to have it do is only return the data if it has all the relevant data in it, so using “And” but only if the cells (E.g. C4, C6, E4, E6 ETC) have data in them. <o></o>
è Basically i want to be able to both board and narrow queries using this macro <o></o>
I am sure there is a very easy way to do this but I am unsure of how to do it ! <o></o>
<o> </o>
Any help would be very much appreciated <o></o>
<o> - </o>Sov <o></o>