We'd like to remind Forumites to please avoid political debate on the Forum... Read More »
We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
Excel MS Query criteria
Options

Ant555
Posts: 1,596 Forumite


in Techie Stuff
I have done this before but can't for the life of me remember how I did it.
In Excel how can I ask the user to enter/specify the 'start date'and !nd date' to run a data query on.
I can get the data using set criteria if I enter it manually in the MS Query boxes (Excel 2013 right click in data then #table #edit query) which is fine for this run but ideally I want the user to enter the specific dates each time.
Many thanks
In Excel how can I ask the user to enter/specify the 'start date'and !nd date' to run a data query on.
I can get the data using set criteria if I enter it manually in the MS Query boxes (Excel 2013 right click in data then #table #edit query) which is fine for this run but ideally I want the user to enter the specific dates each time.
Many thanks
0
Comments
-
Are you willing to VBA it? If so use input box function and date and time picker control depending on what your trying to do0
-
Input box would be my preferred option as well. Ask the user to input the dates, populate spare cells (I used A6 & A7 in the example below) with them, and use these for the query.
Or just have the query in VBA as well. Input box code is simple to use:Sub Get_Date() Dim strDate As String Dim endDate As String strDate = InputBox("Insert start date in format dd/mm/yyyy", "User date", Format(Now(), "dd/mm/yyyy")) Range("A6") = strDate endDate = InputBox("Insert end date in format dd/mm/yyyy", "User date", Format(Now(), "dd/mm/yyyy")) Range("A7") = endDate ' Your query goes here End Sub
0 -
Thanks for the replies - I found an old spreadsheet which revealed how I did it last time.
I simply added
>[START DATE] And <[END DATE]
as the criteria for the date range in MS Query - when you refresh, Excel asks the user to enter [START DATE] AND [END DATE] and returns relevant data as long as you put the right dates in there. There is no error checking that the start date is earlier than the end date etc but for this purpose that is fine.
Cheers.0 -
Great
. Just remember dates are one of the hard things, even for professionals, in computing. <[End Date] means 'before the first microsecond of that date', so isn't inclusive. Date formats also cause issues thanks to Americans being out of step with the sensible world and 10/5/2016 meaning either 5th Oct or 10th May depending on some settings you may not have explicitly overridden. Instead, try to always use YYYY-MM-DD which should be unambiguous
0
This discussion has been closed.
Confirm your email address to Create Threads and Reply

Categories
- All Categories
- 350.8K Banking & Borrowing
- 253.1K Reduce Debt & Boost Income
- 453.5K Spending & Discounts
- 243.8K Work, Benefits & Business
- 598.7K Mortgages, Homes & Bills
- 176.8K Life & Family
- 257.1K Travel & Transport
- 1.5M Hobbies & Leisure
- 16.1K Discuss & Feedback
- 37.6K Read-Only Boards