Importing Text File

G

gunny1979

Hi Guys,

has anyone got a macro where I can import a text file saved on my
computer into a new sheet named yesterdays or todays date in format
"ddmmyy" and then the sheet gets hidden.

Thanks in advance for your help

Gunny
 
C

colofnature

Sub ImportData()
ThisWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = Format(Date, "ddmmyy")
Workbooks.Open FileName:="C:\text.txt", Format:=2
Cells.Copy ThisWorkbook.Sheets(Format(Date, "ddmmyy")).[a1]
Workbooks("text.txt").Close savechganges:=False
Sheets(Format(Date, "ddmmyy")).Visible = False
End Sub

Change "C:\text.txt" to refer to your file. I've assumed that the file
is comma-delimited. If it's not, change the "Format:=2" to whatever you
need it to be (check Help for the Open method for the options).

Col
 
I

Ivan Raiminius

Hi Gunny,

use macro recorder. In case you will need to modify the recorded code,
post it in the forum.

Regards,
Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top