Extracting Data

dramey1

New Member
Joined
Jun 21, 2017
Messages
22
Hey everyone, I'm having some trouble getting started with a code for extracting data from different workbooks. I want to be prompted what file i want to take the data from. At my company we save copies of the same workbook into individual clients files. Each file is in the same drive. Each piece of data is in the same cell in each file. Ideally, I would like to click a button, select my desired file, data appears in sheet, print specific sheet to pdf. Thanks in advance for any help.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi dramey1,

This code should get you started. Place this code in a workbook that is saved in the same location as your client files. Unfortunately your post is too vague for me to do anything else with it.

Code:
Sub GetFile()


    Dim wb As Workbook
    Dim selectedFile As String, strPath As String
    
    strPath = ThisWorkbook.Path
    With Application.FileDialog(msoFileDialogOpen)
        .InitialFileName = strPath & "\"
        .Title = "Select A File To Open"
        .Show
        If .SelectedItems.Count > 0 Then
            selectedFile = .SelectedItems(1)
        Else
            Exit Sub
        End If
    End With
    Set wb = Workbooks.Open(selectedFile)


End Sub

I hope this helps.
 
Last edited:
Upvote 0
igold,

Thanks for getting me started. I think i can take it from here. If I need anymore help ill get back to you, and i will let you know what i figure out.
 
Upvote 0
Happy to help. Thanks for the feedback. Good luck.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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