ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text to columns -- reset delimiters, etc (https://www.excelbanter.com/excel-programming/311980-text-columns-reset-delimiters-etc.html)

Myrna Larson

Text to columns -- reset delimiters, etc
 
If you have used Data/Text to Columns, Excel remembers what your settings were
for delimiters, etc.

Here's my predicament. I had used the Text to Columns on some data that I had
pasted into a worksheet from a newsgroup message, using the space delimiter.

Then I closed that workbook and opened one of my own workbooks without
restarting Excel in between.

In my workbook, I need to paste some tab-delimited data that I copy to the
clipboard in MS Money. Normally, I just copy the data in Money, switch to
Excel, and press CTRL+V to paste. I don't have to use Text to Columns at this
point.

Tonight, the parsing was all messed up because and XL "remembered" that I had
set the Text to Columns delimiter to a space, and it was using those same
settings to parse the new data pasted from the clipboard.

I fixed the problem by closing Excel, restarting, opening the workbook again,
and pasting.

Is there a way, in code, to re-set Text to Columns back to the defaults, or
just to change the delimiter, other than by opening a text file? I can't find
any references to these settings other than the arguments to the OpenText
method.

Or do I have to restart Excel? Or stop messing around with data from newgroup
messages <g?


Myrna Larson

Text to columns -- reset delimiters, etc
 
I came up with this. It's called from my Workbook_Open routine. It seems like
a kludge. Does anybody have a better solution?

Sub SetDelimiters()
Dim Rng As Range
Set Rng = Worksheets("Sheet1").Range("Dummy") 'a normally empty cell
With Rng
.Value = "XXX"
.TextToColumns Destination:=Rng, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
Tab:=True, Semicolon:=False, Comma:=False, Space:=False, Other:=False
.ClearContents
End With
End Sub



On Wed, 29 Sep 2004 22:47:26 -0500, Myrna Larson
wrote:

If you have used Data/Text to Columns, Excel remembers what your settings

were
for delimiters, etc.

Here's my predicament. I had used the Text to Columns on some data that I had
pasted into a worksheet from a newsgroup message, using the space delimiter.

Then I closed that workbook and opened one of my own workbooks without
restarting Excel in between.

In my workbook, I need to paste some tab-delimited data that I copy to the
clipboard in MS Money. Normally, I just copy the data in Money, switch to
Excel, and press CTRL+V to paste. I don't have to use Text to Columns at this
point.

Tonight, the parsing was all messed up because and XL "remembered" that I had
set the Text to Columns delimiter to a space, and it was using those same
settings to parse the new data pasted from the clipboard.

I fixed the problem by closing Excel, restarting, opening the workbook again,
and pasting.

Is there a way, in code, to re-set Text to Columns back to the defaults, or
just to change the delimiter, other than by opening a text file? I can't find
any references to these settings other than the arguments to the OpenText
method.

Or do I have to restart Excel? Or stop messing around with data from newgroup
messages <g?




All times are GMT +1. The time now is 05:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com