To the experts:
I am looking for some VBA statements solving my problem:
I wrote a macro that produced a new worksheet with data selected data from a database worksheet. The macro does not expect more worksheets in the workbook. I recently found out that a user added more sheets for own use. This may cause the macro works on the wrong sheet.
I am looking for a small piece of VBA code as starter of my macro. It must perfom the following task:
• Test on one or more worksheets on the workbook – how do I get the number of sheets?
• If a sheet has the name “Database_yy-mm-dd” (=today) than make this the active sheet
• Ask the user sheet by sheet which contains the database.
• When question is answered with ‘yes’ then rename (or in case one sheet is found) that sheet to “Database_yy-mm-dd” (yy-mm-dd is today)
• Make the database sheet active so that the rest of the code will work on that sheet.
Normally I find the VBA code via the recording function, but I could not find a test on all worksheet names.
Thanks for your help.
Paul
I am looking for some VBA statements solving my problem:
I wrote a macro that produced a new worksheet with data selected data from a database worksheet. The macro does not expect more worksheets in the workbook. I recently found out that a user added more sheets for own use. This may cause the macro works on the wrong sheet.
I am looking for a small piece of VBA code as starter of my macro. It must perfom the following task:
• Test on one or more worksheets on the workbook – how do I get the number of sheets?
• If a sheet has the name “Database_yy-mm-dd” (=today) than make this the active sheet
• Ask the user sheet by sheet which contains the database.
• When question is answered with ‘yes’ then rename (or in case one sheet is found) that sheet to “Database_yy-mm-dd” (yy-mm-dd is today)
• Make the database sheet active so that the rest of the code will work on that sheet.
Normally I find the VBA code via the recording function, but I could not find a test on all worksheet names.
Thanks for your help.
Paul