working with .txt files in a macro

P

Peggy

I'm trying to open a file folder so I can then open a .txt file. The .txt
files will all have unique numbers against them and I cannot figure out how
to tell my macro to open the folder but let me choose the .txt file I need to
open.
 
C

CLR

Maybe this willh help............

Sub Getfile()
'===========================================
'Offers pop-up to allow user to select file to be opened, then opens it
'===========================================
Dim FileToCheck
FileToCheck = Application.GetOpenFilename("Excel file to test (*.xls),*.xls")
If FileToCheck <> False Then
On Error Resume Next
Workbooks.Open FileName:=FileToCheck
End If
End Sub
 
P

Peggy

Thank you for this code. It works really well, and I've tweaked it to open
..txt files. How do I format the spreadsheet as it is reading everything in
one cell. meaning I have a complete sentence in one cell, whereas I need the
information all in separate cells. Any easy tips, rather than writing
lengthy 'if' formulas?!!

Thanks for your help.
Kind regards,
Peggy
 
C

CLR

Try this.......

Data > TextToColumns > Delimited > select "space" for the delimiter.......

Vaya con Dios,
Chuck, CABGx3
 

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