Filename wildcard

bartoni

Active Member
Joined
Jun 10, 2003
Messages
296
I have a macro that asks for the prefix to a workbook name. The suffix is always the same and the depending on the prefix added byt he user depends ont ehw workbook opened.

i.e if user inputs "UK", uk_promo.xls opens
if user inputs "canada", canada_promo.xls opens


I have only one macro which consists of copying and pasting data from the promo sheet to other sheets. I would like to be able to select the sheet based on the suffix i.e. *_promo.xls rather than the whole filename as this changes depending on what the user has input. Does anyone know how to do this? At the moment, the macro will only work with a uk promo workbook.

ActiveWindow.WindowState = xlMinimized
Windows("UK_PROMO.xls").Activate
ActiveWindow.WindowState = xlMaximized
Sheets("promo qtr").Select
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
Hi!
try this one
Code:
fname=userinput & "_promo.xls"
ActiveWindow.WindowState = xlMinimized 
Windows(fname).Activate 
ActiveWindow.WindowState = xlMaximized
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,100
Messages
5,768,095
Members
425,452
Latest member
htay44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top