working with .txt files in a macro

  • Thread starter Thread starter Peggy
  • Start date Start date
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.
 
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
 
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
 
Try this.......

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

Vaya con Dios,
Chuck, CABGx3
 
Back
Top