Can someone please help me

Katy Jordan

Well-known Member
Joined
Jun 28, 2008
Messages
596
hi, i am new to excel and VBA, and hope I can find some answers on this board

I have searched the forum regarding copying data from multiple worksheets into a main workbook, but I did not find anything that tells me how to copy data from multiple csv files into one workbook tab, I can see a thread created by Hiport which is very similar to what I want.
Basically I have a CSV file saved for each day of the month, these files are saved in their monthly folders, so all the CSV files for May will be saved in U:\Custodians\Interest\Year\Month(May2008), now in this folder will also be a master workbook called “Interest-May2008”.
What I do next is very manual, I have to copy from each CSV file, data from Col 1 and Col2 and paste this to the master workbook- sheet (downloads), all the data will be pasted next to each other, i.e. col 1 and 2 will be data for 01-May-08, and col 3 and 4 will have data for 02-May-08 etc, as you can see it’s a very daunting task having to go through each file and copy and paste.
I need a macro written so it copies data in col 1 and 2 in each csv file and then pastes that data in a master workbook sheet (downloads), the data will be in date order of the CSV files, I want the data pasted in row 3 of the master workbook (downloads).
I hope someone can solve my misery, you will save me 45 minutes of pain of copy and pasting.
 
Ok now i get the below error for the following part of the code
Compile error:
ByRef argument type mismatch, its higlighting

Code:
myList



Code:
Sub test()
    myN = 0
    SearchFiles "U:\NRFF", "MS", ".csv"
    If n > 0 Then
        GetMyCSV myList
    Else
        MsgBox "No file in the folder"
    End If
End Sub




delete ")" after 1
Code:
temp = Mid$(myFile.Name, Len(myFileName)+1,4)
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Can you change
Rich (BB code):
    If n > 0 Then
        GetMyCSV 2,4
    Else
to
Rich (BB code):
    If myN > 0 Then
        GetMyCSV 2,4
    Else
 
Upvote 0
nope still says no file in folder, i kept GetMyCSV 2,4 else if i put my List i get that argument error

Code:
Sub test()
    myN = 0
    SearchFiles "U:\NRFF", "MC", ".CSV"
    If myN > 0 Then
        GetMyCSV 2, 4
    Else
        MsgBox "No file in the folder"
    End If
End Sub
Can you change
Rich (BB code):
    If n > 0 Then
        GetMyCSV 2,4
    Else
to
Rich (BB code):
    If myN > 0 Then
        GetMyCSV 2,4
    Else
 
Upvote 0
Can you just change
Rich (BB code):
If myFile.Name Like myFileName & "####" & myFileType Then
to
Rich (BB code):
If myFile.Name Like myFileName & "*" & myFileType Then
 
Upvote 0
OK now is get a runtime mismatch around this code

Code:
myDate = DateSerial(Year(Date), Mid$(temp, 3), Left$(temp, 2))

Can you just change
Rich (BB code):
If myFile.Name Like myFileName & "####" & myFileType Then
to
Rich (BB code):
If myFile.Name Like myFileName & "*" & myFileType Then
 
Upvote 0
Hummm
How about
Code:
myDate = DateSerial(Year(Date), Val(Mid$(temp, 3)), Val(Left$(temp, 2)))
 
Upvote 0
Other way around...
should be
Rich (BB code):
myList(1, myN) = myDir & "\" & myFile.Name: myList(2, myN) = myDate
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,273
Members
449,219
Latest member
daynle

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