Lookup Macro Help

Sovrenty

New Member
Joined
Mar 15, 2011
Messages
1
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:
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
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p> </o:p>
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:p></o:p>
è Basically i want to be able to both board and narrow queries using this macro <o:p></o:p>
I am sure there is a very easy way to do this but I am unsure of how to do it ! <o:p></o:p>
<o:p> </o:p>
Any help would be very much appreciated <o:p></o:p>
<o:p> - </o:p>Sov <o:p></o:p>
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Watch MrExcel Video

Forum statistics

Threads
1,122,842
Messages
5,598,394
Members
414,234
Latest member
grlevesq

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
Top