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
42 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 51

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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