Range of Object Global Failed Text to Column Macro

Jammydodger43

New Member
Joined
Sep 28, 2018
Messages
5
Hi,

Trying to right a simple macro to run the text to column function on the selected column and return the value to the same column but as text. I got to the below, it works if I set the range as an absolute cell reference but need it to return to the same range as I select, I have tried setting the current selection as a range and then referencing that as the range in the text to column function but it just returns the error Range of Object Global_ failed.


Code:
Sub Text_To_Column_Text()
'
' Text_To_Column_Text Macro
'
' Keyboard Shortcut: Ctrl+Shift+D
'
Dim myRange As Range
Set myRange = Selection
   
Selection.TextToColumns Destination:=Range("myRange"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, OtherChar _
        :="/", FieldInfo:=Array(1, 2), TrailingMinusNumbers:=True
End Sub

Any help would by massively appreciated!

James
 
Last edited by a moderator:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,215,404
Messages
6,124,715
Members
449,184
Latest member
COrmerod

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