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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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