Setting Text to Column Delimiters

focuswiz

New Member
Joined
Aug 12, 2014
Messages
20
Though I could not find it, I am sure that this question has been answered or that the answer should be obvious, but I would appreciate any guidance offered.

Recently, I have been using data from external applications in Excel and have been using a simple "Activesheet.Paste" command in my VBA prior to processing the data.

One afternoon, the data started being pasted wrong and some investigation unearthed that this operation uses the parameters in the "Text to Columns" wizard to define delimiters. At some point I must have converted a column of data to text using a comma as a delimiter so sentences and amounts were now being split at the commas rather than at the tabs which had been the prior and expected behavior.

I am wondering what is a good way to set these parameters back to their standard values prior to running these scripts (just in case something else I have run has changed the defaults).

I know how to set the various delimiter options to true or false when I am doing Range.TextToColumns() in VBA and built a somewhat absurd script that does what I need, but I have to believe there is an easier way to set these parameters in a VBA script.

For example, this is what I am using to set the delimiters back to the defaults (as you can see it does a lot to not do anything but set the delimiters):
VBA Code:
Sub SetDelimiters()
    Dim wsTemp As Worksheet
    Set wsTemp = Sheets.Add
    wsTemp.Range("A1").Value = "Test"
    wsTemp.Range("A1").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
        ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False, Space:=False, Other:=False
    Application.DisplayAlerts = False
    wsTemp.Delete
    Application.DisplayAlerts = True
End Sub
This code sets the parameters to their standard values to "fix" any setting they may have had so that the paste command will work as expected.

Thanks in advance.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top