Problem in Converting from textfile to Worksheet

  • Thread starter Thread starter Poornima
  • Start date Start date
P

Poornima

Hi,
I want to convert the contents of a text file to a worksheet in my
workbook. The following code helps me to move the contents but the
allignment is all wrong.

Your_File_Name = "txtShipmentReport.txt"

Open Your_File_Name For Input As #1
Sheets.Add

Do While Not EOF(1)
Line Input #1, Data_From_File
Range("A1").Offset(Y, 0) = Data_From_File

Y = Y + 1
Loop
Close #1

Is there any way to solve this??? I tried using the following code
also:

Call Workbooks.OpenText(txtShipmentReport, , , ,
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True)

But it creates a new workbook, which i do not want.

I have to convert 3 text files and then search on a few conditions to
create the final output.

I'm new to VBA and hence am really stuck with this thing. Anybody out
there can help me would b really wonderful.

Thanks in Advance,
Poornima.
 
No help or solution this but only a simpleton's workaround-
until you've got a solution to your VBA coding what's
stopping you doing an import manually using the text
import wizard and then re-formatting as you need (not
forgetting the paste special function- using values only-
to maintain the formatting of any worksheet you're
importing into)? I assume that this is a task performed
many times on lots of data and that's why you want to
automate the process?
Dominic
 
Back
Top