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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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