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):
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.
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
Thanks in advance.