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
39 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 50

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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Clear a Text Box 7 28
Transposing this formula ... 5 16
New Email window show up in front of any other window 3 16
NEED TRANSFER  DATA 59 23
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.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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 a scrolling table in Microsoft Excel using the INDEX function.

830 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