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.
 
how do i adjust this code in order for the macro to extract any given month given to the file, say it might be Interest-May, or Interest-January etc
1) change to
Rich (BB code):
Sub test()
    myN = 0
    SearchFiles "U:\NRFF", "MC", ".CSV"
    If myN > 0 Then
        GetCSV 1, 2, 4
    Else
        MsgBox "No file in the folder"
    End If
End Sub
2) change to
Rich (BB code):
wsName = "Interest-" & MonthName(ForMonth), False) & ".xls"
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Thanx Jindon for that.


1) change to
Rich (BB code):
Sub test()
    myN = 0
    SearchFiles "U:\NRFF", "MC", ".CSV"
    If myN > 0 Then
        GetCSV 1, 2, 4
    Else
        MsgBox "No file in the folder"
    End If
End Sub
2) change to
Rich (BB code):
wsName = "Interest-" & MonthName(ForMonth), False) & ".xls"
 
Upvote 0
Jindon, i am getting a compile error "Expected end of statement" around the follwoing code

Code:
wsName = "Interest-" & MonthName(ForMonth),False) & ".xls"


1) change to
Rich (BB code):
Sub test()
    myN = 0
    SearchFiles "U:\NRFF", "MC", ".CSV"
    If myN > 0 Then
        GetCSV 1, 2, 4
    Else
        MsgBox "No file in the folder"
    End If
End Sub
2) change to
Rich (BB code):
wsName = "Interest-" & MonthName(ForMonth), False) & ".xls"
 
Upvote 0
OOps, ")"...
Should be
Rich (BB code):
wsName = "Interest-" & MonthName(ForMonth,False) & ".xls"
 
Upvote 0
Ok i put the amended code, and now i get an compile error: "Wrong number of arguments or invalid property assignment" around this piece of code, highlights "GetMyCSV' in grey

Code:
GetMyCSV 1, 2, 4


OOps, ")"...
Should be
Rich (BB code):
wsName = "Interest-" & MonthName(ForMonth,False) & ".xls"
 
Upvote 0
Rich (BB code):
Sub GetMyCSV(Column1 As Integer, Column2 As Integer)
should be
Rich (BB code):
Sub GetMyCSV(ForMonth As Integer, Column1 As Integer, Column2 As Integer)
 
Upvote 0
ok, i changed that and now i get an compile error: User-defined type not defined

highlights all of the below code in grey

Code:
Sub GetMyCSV(ForMonth As Interger, Column1 As Integer, Column2 As Integer)


Rich (BB code):
Sub GetMyCSV(Column1 As Integer, Column2 As Integer)
should be
Rich (BB code):
Sub GetMyCSV(ForMonth As Integer, Column1 As Integer, Column2 As Integer)
 
Upvote 0
OOps, typo
Rich (BB code):
Sub GetMyCSV(ForMonth As Integer, Column1 As Integer, Column2 As Integer)
 
Upvote 0
how do i adjust this code in order for the macro to extract any given month given to the file, say it might be Interest-May, or Interest-January etc

I think I misread the question...

Can you explain a little clearer ?
 
Upvote 0

Forum statistics

Threads
1,216,102
Messages
6,128,852
Members
449,471
Latest member
lachbee

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