Importing data from a lot of differente .csv files

joszepereira

New Member
Joined
Mar 24, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello guys,

I'm new at the forum and i'm looking for some help solving my problem.

I have a lot of different .csv files with data - 1 file per day named with the date, for example: 2020_03_23_data.csv.

What I need to do is something like: give the input of the day, month and year I want to consult, in 3 different cells, and then Excel would actualize the data with the correspondent file.
Is it possible?

Thank you in advance.

José
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Maybe

VBA Code:
Option Explicit

Sub GetCSV()
    Dim Day As Long, Mnth As Long, Yr As Long
    Day = Range("A2")
    Mnth = Range("B2")
    Yr = Range("C2")
    Dim Path As String
    Path = "C:\Users\etc\"  'set the path where your csv file is located
    Workbooks.Open Path & Yr & "_" & Mnth & "_" & Day & "_" & "Data.csv"
End Sub
 
Upvote 0
Maybe

VBA Code:
Option Explicit

Sub GetCSV()
    Dim Day As Long, Mnth As Long, Yr As Long
    Day = Range("A2")
    Mnth = Range("B2")
    Yr = Range("C2")
    Dim Path As String
    Path = "C:\Users\etc\"  'set the path where your csv file is located
    Workbooks.Open Path & Yr & "_" & Mnth & "_" & Day & "_" & "Data.csv"
End Sub

Hello @alansidman

Thank you for the answer.
It works, but it doesn't import the data to my workbook. Do you know how can I do that?

José
 
Upvote 0
@joszepereira
While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Where would you like the data in the file that has been opened to be imported to. Sheet? Range? Appended to existing Data? More information please. You have only indicated in the first post that you wanted to get the file. Nothing about importing. We are pretty good here at Excel but terrible at mind reading. Help us to help you by giving us maximum information about your issue.
 
Upvote 0
I'm sorry about the crosspost. I'm just worried about doing this and didn't read the rules.

I will try to explain the better I can:

I have a folder in a certain path with a lot of different csv files.
All of them are named with the date: like "2020_03_23_data.csv".
I need an excel file to do the following: import all the data to a new worksheet, based in my input with the year, month and date I want to consult.
The table headers are in line 3 and the data is in the line 5 and down.

Thank you,
José
 
Upvote 0
Are you appending this data to existing data? Really need to know where it is going. Where is it to be imported? You still have not given us enough information. This is my last ask. If you are unwilling to help us by giving full information then I don't have any further time for this issue.
 
Upvote 0
You can waste the time you want. I'm trying to give you the information…

The idea is to import the data to a worksheet. If i run the macro again, it should replace the data that was before in that place. This way, I can update the pivot table and atualize the data in it.

José
 
Upvote 0
Good bye. Good luck finding a solution. I can no longer assist you.
 
Upvote 0

Forum statistics

Threads
1,223,799
Messages
6,174,669
Members
452,576
Latest member
AlexG_UK

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