Linking CSV with XLSX

Nanaia

Board Regular
Joined
Jan 11, 2018
Messages
235
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
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,954
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
 

Nanaia

Board Regular
Joined
Jan 11, 2018
Messages
235
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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...
 

Nanaia

Board Regular
Joined
Jan 11, 2018
Messages
235
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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.
 

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,954
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:

Nanaia

Board Regular
Joined
Jan 11, 2018
Messages
235
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,499
Messages
5,596,515
Members
414,074
Latest member
Matthew Kakde

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
Top