code for text to columns

V

Vato Loco

Let's say I want a worksheet to do "text to columns" (delimited) ever
time it opens?

For example: Text to columns, delimited, by space for column A.

Thanks again all...Vat
 
J

jeff

Hi, Vato,

Add this code to your main sheet module1.bas.(In VB
editor, menu Insert->Module)

Sub auto_open()
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote,
ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True,
Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)),
TrailingMinusNumbers:=True
End Sub

jeff
 
N

Nick Hodge

Vato

Try recording yourself doing it.

Tools>Macros>Record new macro...

If the generated code needs modification, or doesn't do exactly as you need,
post back with an updated description of your need beyond what you have

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
[email protected]
 
Top