![]() |
VBA Search Date Range and Populate Spreadsheet Cells
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~ |
VBA Search Date Range and Populate Spreadsheet Cells
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 he http://nickhodge.co.uk/gui/datamenu/...taexamples.htm http://www.dicks-clicks.com/excel/Ex...htm#Parameters -- Regards, Tom Ogilvy "Diana" wrote: 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~ |
VBA Search Date Range and Populate Spreadsheet Cells
On Mar 14, 2:00 pm, Tom Ogilvy
wrote: 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 hehttp://nickhodge.co.uk/gui/datamenu/...aldataexamples... http://www.dicks-clicks.com/excel/Ex...htm#Parameters -- Regards, Tom Ogilvy "Diana" wrote: 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~- Hide quoted text - - 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! |
VBA Search Date Range and Populate Spreadsheet Cells
There are too many great contributors here - fortunately their wisdom is
archived on Google Groups! -- Regards, Tom Ogilvy "Diana" wrote in message oups.com... On Mar 14, 2:00 pm, Tom Ogilvy wrote: 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 hehttp://nickhodge.co.uk/gui/datamenu/...aldataexamples... http://www.dicks-clicks.com/excel/Ex...htm#Parameters -- Regards, Tom Ogilvy "Diana" wrote: 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~- Hide quoted text - - 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! |
All times are GMT +1. The time now is 07:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com