-
Lookup Macro Help
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:
[VBA]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
[/VBA]
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.
θ Basically i want to be able to both board and narrow queries using this macro
I am sure there is a very easy way to do this but I am unsure of how to do it !
Any help would be very much appreciated
-GRAm
-
Hi Gram
Welcome to VBAX.
Can you post your workbook?. Use manage attachments in the Go Advanced reply section. Please add any comments etc. to make clear what you are after.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules