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:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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