select file, have a preview screen of data within selected file, choose data to be copied

kel122

New Member
Joined
Apr 9, 2018
Messages
1
Hi everyone,

I am very new to VBA and did not know how to really word the title.

I am currently working on a project at work which involves copying certain data from a selected file to the current workbook.

Step 1: I want to create a userform where the user can click a button and a dialog box opens so the user can select the desired file.

Below is a piece of code where I took from another topic which was created by Trebor76.
---------------------------------------------------
Sub OpenDesiredWB()


Dim SelectedWB As Workbook
Dim SelectedPath As String

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Title = "Please select a file to open:"
.Filters.Add "Excel and CSV files", "*.csv; *.xls; *.xls*", 1
.Show
On Error Resume Next 'In case the user has clicked the button
SelectedPath = .SelectedItems(1)
If Err.Number <> 0 Then
Exit Sub 'Error has occurred so quit
End If
On Error GoTo 0
End With

Set SelectedWB = Workbooks.Open(SelectedPath)


End Sub
------------------------------------------

Step 2: Once they have selected the file, a preview screen of the data within the selected file shows up in the current workbook so that they user can select whatever rows or columns they want to copy over.

Step 3: The user can now select on the userform the destination of where the copied data will be pasted to. For example : Sheet1, Range "A2." This will give the user the flexible to find the last row and copy it correctly.

Step 2 and 3 is where I am stuck at. If you need any part to be better explained, please let me know. Been stuck on this issue for 2 days. Also,
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,952
Messages
6,175,593
Members
452,654
Latest member
mememe101

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