macro help

elyse

New Member
Joined
Sep 10, 2002
Messages
2
Dear Macro Wizards,
I'm new to the world of writing macros and was wondering if y'all could help. I have a couple general questions, if they aren't clear I can provide more specific examples....

Is it possible to write a macro that opens a number of excel spreadsheets in a certain folder that have different names using "shift + enter"?

i.e. in a folder called "examples" can I have a macro that will open files called "example1.xls," example2.xls," example3.xls," etc using shift + enter?

Also, once all of my spreadsheets are open, can I write if-then functions based on the file names?

i.e. If the file name contains the number 1 then cut the value in "D2" and paste in another spreadsheet cell "B2"; if the file name contains the number 2 then cut the value in "D2" and paste in another spreadsheet cell "F2"; etc...

I think in order to have a macro do what I want it to, I need to use wildcard type functions, how do macros handle wildcards?

Thanks for the help!!

-Elyse
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,028
Yes, you can open multiple files with a macro. If you don't know the names of the files (and want someone to select them at run time), use the GetOpenFilename method. Look it up in XL VBE help. Note that the last argument controls on whether multiple files can be selected.

Don't know if you were looking for pointers or a readymade solution. Hopefully, it is the former...

As far as the 'If' part goes, sure, just use it. Check help for more on the syntax. Interestingly enough, the only (for me at least) way to find the If statement in help is to search for 'Else' (w/o the quotes).

To check if a particular string is part of another string (checking if "1" is part of the filename), use InStr.
 

elyse

New Member
Joined
Sep 10, 2002
Messages
2
Thanks for the tips Tushar, unfortunately even after looking at the syntax in the help file, I still can't figure out how to the get the GetOpenFilename method with the Multiselect modifier to work. I'm REALLY new at this!

Someone, please enlighten me!

Thanks so much!

-Elyse
 

Watch MrExcel Video

Forum statistics

Threads
1,118,069
Messages
5,570,010
Members
412,304
Latest member
citrus
Top