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
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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