Linking CSV with XLSX

Nanaia

Active Member
Joined
Jan 11, 2018
Messages
306
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Good Monday morning to you!
Is there a way to make it so an XLSX will pull data/reference a CSV file in the same folder? Right now I'm simply opening both files, copying the CSV and pasting the data into a tab in the XLSX. I was wondering if there was a way to eliminate the need for the copy and paste, if the CSV (since it's the only one of that format in the file) could have the data retrieved from it another way. Am I out of my mind thinking this can be done? That maybe I just need to wait for my coffee to kick in before I start asking questions...?
Regards,
Nanaia
"Do or do not, there is no try"~Yoda
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
use data import,
DATA tab, from TEXT


Code:
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Users\BobSmith\Desktop\MyData.txt", Destination:=Range( _
        "$A$1"))
        .CommandType = 0
        .Name = "METER READS AIR"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 437
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
 
Upvote 0
Ranman256 - Thank you~
Could I impose on you to tell me what I'm supposed to do with this information...because it doesn't look like something I just put into my spreadsheet...? I'm used to dealing with formulas, this is a bit more complex...
 
Upvote 0
Just for clarification, this would be for a template sheet that would end up being saved to each job folder. (I mis-spoke before, there is only one CSV in the folder. I'd originally said there's only one CSV in the file.) We would open and save as or copy the template XLSX and rename it. I don't even know if what I want to do is possible, but figured this would be the place to ask.
 
Upvote 0
The code would set in a module in the xl template. The youd modify it to import the csv file you want, (TEXT;C:\Users\BobSmith\Desktop\MyData.txt)
then it would SAVEAS to the job folder
 
Last edited:
Upvote 0
Thank you.
Based on your description, and other information I've found online, this is something that would have to be done every time a new version of the file was saved in the new job folder, correct?
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top