VBA Search Date Range and Populate Spreadsheet Cells

D

Diana

Hello, I'm new to this forum, but am desperately seeking some Excel
VBA help...

What I have is a spreadsheet that autopopulates several fields from a
SQL Query Macro into specific cells on the sheet. The fields contain
Date, Item#, Item Name, etc.

What I have done was create a UserForm that requests that the user
input a Start Date and an End Date in its' textboxes...and would
ultimately like this UserForm to search the Date field of the
spreadsheet for the date range provided by the user and pull those
records in the spreadsheet by re-populating the starting cell (where
the SQL Query begins upon opening the spreadsheet).

The problem is...I really have no idea where to begin with the
UserForm code, or if this is even possible. Can I use a UserForm to
pull and populate the sheet, or do I need to add onto the SQL Query
Macro to request that the user input the desired date ranges after the
Query runs upon opening the sheet?

Hopefully this all makes sense, I have been grinding through a lot of
articles but cannot find something specific to my needs.

If you need more information, I can provide as much as I have.

Thank you in advance for all of your help!

~Diana Peterson~
 
D

Diana

Use the workbook_Open event (found in the ThisWorkbook module) to show the
userform and get the dates. Then build the SQL querystring to incorporate
the dates provided by the user, then execute the query using this string.

http://www.cpearson.com/excel/events.htm

if you are using a querytable then look here:http://nickhodge.co.uk/gui/datamenu/dataexamples/externaldataexamples...

http://www.dicks-clicks.com/excel/ExternalData6.htm#Parameters

--
Regards,
Tom Ogilvy












- Show quoted text -

Thank you so much Tom, you have made my life much easier by providing
me the tools to get ahead. I really appreciate your help with pointing
me i the right direction!

I've noticed that you have been the main answerer to many of the
questions posed on this website. Perhaps someday we will gather all of
your personal help and make a website dedicated to your expertise. =P
Providing you would accept such a demand of your intelligence!!

Hehe...thanks again!
 
T

Tom Ogilvy

There are too many great contributors here - fortunately their wisdom is
archived on Google Groups!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top