read file size and Write it to exel

newapa

Board Regular
Joined
Sep 13, 2012
Messages
69
Hey guys!


I have a csv file like this.

2012-09-10 meat spaghetti
2012-09-11 fish fish and chips
2012-09-12 meat hamburger
etc.
etc.


and I want to read it and write it to excel. So far I have come with my code but I'm stuck. so I wonder if anyone has some tips or can help me?
I was thinking like this. to read the file size, then put it in a string$ after that i split it up that meat is in sheets1 and fish in sheets2 and salad in sheet3. and cell 1 get the date and cell 2 get the meat and cell 3 get the spaghetti.

so heres my code

Code:
Sub ImpFile()

    Dim ws As Worksheet, iFileNo As Integer
    Dim s1 As String, s2 As String
    
    Set ws = ThisWorkbook.Worksheets("sheets1")
    
    s2 = "sampel.csv"
     
  
    iFileNo = FreeFile()
    Open s2 For Binary As #iFileNo

    s1 = String$(FileLen(s2), 0)


------i'm stuck here------


    Close #iFileNo
End Sub

sorry i'm new in vba.
thanks in advance
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
This will give the size - just replace with your file and path names
Code:
Sub Get_File_Size()
File1 = "L:\ALynn\Sample.csv"
MsgBox "The Size of the File is " & FileLen(File1) & " bytes"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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