clvestin
02-09-2007, 01:44 PM
I'm opening a fixed width dbf file. I copy the file to column a of an excel sheet. I would like to parse the file with the result on Sheet2.
Public Sub t_to_col()
Set col1 = Sheets("sheet1").Columns(1)
Set col2 = Sheets("sheet2").Columns(1)
col1.Copy
Worksheets("sheet2").Activate
col2.Select
Sheets("sheet2").Paste
col2.TextToColumns
End Sub
Public Sub t_to_cols2()
Set col1 = Worksheets(1).Columns(1)
Set col2 = Worksheets(2).Columns(1)
Set rng1 = Worksheets(2).Range("a1:b2")
'Worksheets(2).Activate
'rng1.Activate 'Select
col1.TextToColumns DataType:=xlFixedWidth, Destination:=rng1
End Sub
The first routine will do it but is clumsy.(I don't like the whole Copy/Paste thing). The second is a no go, the result overwrites the data on Sheet 1.
Any suggestions?
Public Sub t_to_col()
Set col1 = Sheets("sheet1").Columns(1)
Set col2 = Sheets("sheet2").Columns(1)
col1.Copy
Worksheets("sheet2").Activate
col2.Select
Sheets("sheet2").Paste
col2.TextToColumns
End Sub
Public Sub t_to_cols2()
Set col1 = Worksheets(1).Columns(1)
Set col2 = Worksheets(2).Columns(1)
Set rng1 = Worksheets(2).Range("a1:b2")
'Worksheets(2).Activate
'rng1.Activate 'Select
col1.TextToColumns DataType:=xlFixedWidth, Destination:=rng1
End Sub
The first routine will do it but is clumsy.(I don't like the whole Copy/Paste thing). The second is a no go, the result overwrites the data on Sheet 1.
Any suggestions?