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

x
?
Solved

Can I link (connect) a table to a dynamic CSV file based on cell values for folder and filename using VBA?

Posted on 2016-09-15
2
Medium Priority
?
54 Views
Last Modified: 2016-10-20
Every month I send a CSV file to different users, that they should analyse in Excel.

I have attached a spreadsheet that has the VBA, that I have been using to import into Excel for them, and this is followed by a pivottable that gives the users the possibility to analyse data.

Unfortunately this does not import data to an Excel Table, which will give me a more flexible way of expanding/change the size of my dataset.

I have created the import and analysis using PowerQuery and it Works great. Unfortunately does many of my users not have access to PowerQuery, and I need to do the same in Basic Excel and use some VBA to do the same trick.

The procedure is called OpenCsv and it imports the data to the the sheet "Vederlagsspecifikation" based on the two inputs of folder and filename in the sheet "Vejledning"

If you have any questions or need to me to clarify my problem, please just ask.

best regards

Jørgen
100575-VL000274.csv
Test-af-import-af-csv-fil.xlsb
0
Comment
Question by:Jorgen
[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
2 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 41799546
Hi,

pls try

Sub Change_DataSource()

 
strNewURL = Sheets("Vejledning").Range("A2") & Sheets("Vejledning").Range("A1")
Set tbl = Sheets("Vederlagsspecifikation").QueryTables(1)
 
With tbl
    If .Connection <> "TEXT;" & strNewURL Then
        .Connection = "TEXT;" & strNewURL
        .Refresh
    End If
End With

End Sub

Open in new window

Regards
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41851697
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:

Accept: Rgonzo1971 (https:#a41799546)

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

604 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