VBA for Popup to select a file

blnswamy

New Member
Joined
Oct 18, 2013
Messages
8
Hi
I am working on a project where i need to create a macro and give it to a user. The task is to create a popup window so that the user can select a file from a folder in their PC.
Thank you
 
The first thing you need to do is open the file the user has selected.
Code:
    Set wbAfter = Workbooks.Open(AfterFileName)
Now what you want to copy isn't exactly clear.

This will copy the first worksheet from wbAfter to the workbook the code is in.
Code:
wbAfter.Worksheets(1).Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)

This will copy the data from the first worksheet to a new sheet in the workbook the code is in.
Code:
Set wsNew = ThisWorkbook.Worksheets.Add

wbAfter.Worksheets(1).UsedRange.Copy wsNew.Range("A1")

Once you are finished with the workbook the user selected you can close it.
Code:
wbAfter.Close SaveChanges:=False
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,537
Messages
6,125,390
Members
449,222
Latest member
taner zz

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