code for text to columns

  • Thread starter Thread starter Vato Loco
  • Start date Start date
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
 
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
 
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
(e-mail address removed)
 

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

Similar Threads


Back
Top