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
20 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
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 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 13

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now