?
Solved

VBA code to ask user to choose source data from a location

Posted on 2016-09-23
5
Medium Priority
?
31 Views
Last Modified: 2016-10-20
Hello experts,

Can anyone provide me a vba code that I use it in a custom button to ask the user to get the source data from a folder / location?

I am trying to create an automate report and the users should be able to choose new raw data from a location.

thanks,
0
Comment
Question by:tony01excel tony
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 17

Assisted Solution

by:John Tsioumpris
John Tsioumpris earned 1000 total points
ID: 41812220
i think you need to read the documentation of FileDialog
Here is small sample in Access VBA
Dim fd As FileDialog
Dim ffs As FileDialogFilters
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
        Set ffs = .Filters
        With ffs
            .Clear
            .Add "Text RAW", "*.csv", 1
        End With
.AllowMultiSelect = False
        If .show = False Then Exit Sub

FullFilePath = .SelectedItems(1)
End With

Open in new window

0
 
LVL 34

Expert Comment

by:Norie
ID: 41812221
Is the source data a workbook or is it something else?
0
 

Author Comment

by:tony01excel tony
ID: 41812225
Hi Norie,

Source data will be another excel workbook, but saved in the same folder as the automated template.
0
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 41812260
Hi,

pls try

ChDir ActiveWorkbook.Path
strFileToOpen = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*")
If strFileToOpen = False Then Exit Sub

Open in new window

Regards
1
 
LVL 14

Expert Comment

by:frankhelk
ID: 41851710
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Rgonzo1971 (https:#a41812260)
-- John Tsioumpris (https:#a41812220)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question