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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi!
try this one
Code:
fname=userinput & "_promo.xls"
ActiveWindow.WindowState = xlMinimized 
Windows(fname).Activate 
ActiveWindow.WindowState = xlMaximized
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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
Back
Top