VBA to prompt user to select two xlsm files

MikeL

Active Member
Joined
Mar 17, 2002
Messages
492
Office Version
  1. 365
Platform
  1. Windows
Hello,
I would like to prompt the user to first select one .XLSM file. I have the code to then filter and paste to a Consolidation.XLSM

Then, I would like the user to be prompted to select a second .XLSM file.

Key VBA Needs:
User prompt to Select file (all files are in A:/Shared but might be in different subfolders)
Open Consolidation.XLSM After WB1 is open
Close WB1 and prompt user to open WB2.

Thanks,
Mike
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Somthing I've got in my current project, though its a bit lenghty

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Don't allow user to make multiple selections in dialog box
.AllowMultiSelect = True

.InitialFileName = strInitPath

'Set the title of the dialog box.
.Title = "Please select xml file"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "XLS or XLSX Files", "*.xls, *.xlsx"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
For Each varFile In .SelectedItems
DoCmd.Hourglass True
LoadXLSFile varFile
SaveXLSFile varFile
strFiles = strFiles & varFile & vbCrLf
DoCmd.Hourglass False
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
Exit Sub
End If
End With

I'm pretty sure with some tweaking that could fill your needs, unless someone has somthing simpler
 
Upvote 0
thanks for the response LD. I will work with that code.
 
Upvote 0
thanks for the response LD. I will work with that code.

NP, hopefully it'll work, you should be able to get rid of some stuff if you need, the msg for example gets annoying (and wasn't coded by me), the hourglass stuff is only if you want it (it can take a while to load the file!)

I should mention the below

LoadXLSFile varFile
SaveXLSFile varFile

refer to my own functions that "do" what I want to do with the file (in this case stick the data into a database

and

strFiles = strFiles & varFile & vbCrLf

is not needed for you at all (I had some more lines that use this var to report back whats been done.
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,448
Members
452,915
Latest member
hannnahheileen

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