Macro for Text to Columns over a set range

virtualmaniac

New Member
Joined
Jun 11, 2015
Messages
2
Hey ladies and gents,

Completely forgot all of my old profile details and no longer have access to my old email so have had to create a new account so I'm not a complete newbie here.

Anyway, I've been creating a system to import dates from an external program. The program exports the dates that are not immediately readable by Excel. I have got the macro to complete the Text to Column function one column at a time (as I know it needs to be completed one column at a time) and I need this to repeat 16 times.

However due to my client's errors occasionally not every column has a date in. When this is the case I need the macro to essentially say, on error, resume to next column, but I cannot get this to work. Any help would be appreciated.

Code:
Sub Data_Fix()
    Selection.TextToColumns Destination:=Range("E5"), DataType:=xlDelimited, _
        TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=True, Semicolon _
        :=False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, _
        4), TrailingMinusNumbers:=True
    Selection.TextToColumns Destination:=Range("F5"), DataType:=xlDelimited, _
        TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=True, Semicolon _
        :=False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, _
        4), TrailingMinusNumbers:=True
End Sub

Thank you!
 
Last edited:

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,512
Office Version
  1. 365
Platform
  1. Windows
Maybe try putting:
Code:
On Error Resume Next
at the beginning of your code and then
Code:
On Error Goto 0
at the end of it.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,082
Messages
5,622,588
Members
415,909
Latest member
vbaBeginner94

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
Top