TextToColumns issue

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
Data from other programs is often a delimited type as seen below in yellow cells. This comes from a text export in this instance.
Code below splits data into columns. This part works.

After the macro is run, for some reason when copying and pasting data which is in tabular format in the other program (not delimited/text), the paste is not as expected.
Thought that a setting is changed from code below. Tried to use Application.CutCopyMode but does not work.
If Excel is shut down and restarted and the source data from other program is copied and pasted, the paste into Excel works as expected.

1714041831994.png


VBA Code:
Sub Split_to_columns()
    Dim MyRange As Range
    Set MyRange = Range("A4:A100")
    'Split data into columns
    Application.CutCopyMode = False
    MyRange.TextToColumns Destination:=MyRange.Offset(0, 1), DataType:=xlDelimited, ConsecutiveDelimiter:=True, Space:=True
    Application.CutCopyMode = True
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Is this, perhaps, what you are experiencing?
 
Upvote 0
Solution
Thanks Joe4, this worked.

Code below is based on links followed.

VBA Code:
Sub reset_ttc()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    On Error Resume Next
    'Temporary workbook
    Workbooks.Add
    With Cells(1, 1)
        .Value = "Any text"
        .TextToColumns Destination:=.Cells, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False, Space:=False, Other:=False, TrailingMinusNumbers:=True, FieldInfo:=Array(1, 1)
        .Clear
        .Worksheet.UsedRange
    End With
    ActiveWorkbook.Close False
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
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