Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2016-09-23
5
Medium Priority
?
32 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 19

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 35

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 53

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

636 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