Import worksheet with dailog box option

softman

New Member
Joined
Mar 5, 2011
Messages
1
Hi,

I am new to vba and have search this forum but could not find the soloution.

I have a file with a worksheet "Master" and want to import that files data into my opend workbook and put the data in a given worksheet "ImportData" and copy the data range for excamle A4:AC50 in to the worksheet. But the user must be asking to find the file an directory and then select the file. (Dialog box open)

Is this possible?

Many thanks.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try this- just copies entire workbook - but it is a start

Code:
Private Sub CommandButton1_Click()
    FilesToOpen = Application.GetOpenFilename("Excel Files (*.xl*)," & "*.xl*", 1, "Select Excel File", "Open", MultiSelect:=True)
    
    For i = 1 To UBound(FilesToOpen)
        Workbooks.Open FilesToOpen(i)
        With ActiveWorkbook
            For ii = 1 To Sheets.Count
                .Sheets(ii).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
            Next ii
            .Close 'closes file after it is copied
        End With
       
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,476
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