Text To Columns macro in Excel 2010

metsmaniac

Board Regular
Joined
Jan 29, 2010
Messages
57
Office Version
  1. 365
Platform
  1. Windows
I want to create a "Text_To_Columns" macro in Excel 2010 that is not restricted to the range within the macro. The purpose of the macro is to be able to select a range of cells that are formatted as text and convert the text to values, so I want to select the range and then run the macro.

The macro below was created by turning on Record Macro, clicking Data=>Text to Columns=>Finish, then turning off the macro. As you can see, it's restricted to range "K36".

Is there a way to modify the macro below to do the above? Thanks in advance.

Sub Text_To_Columns()

' Text_To_Columns Macro

Selection.TextToColumns Destination:=Range("K36"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Not sure why you'd bother writing a macro for use in a way that using the built in function would be about the same effort?

formatted as text and convert the text to values did you columns when you said Values
 
Last edited:
Upvote 0
Speed & efficiency - the essence of macros. 1 click vs. 3, assuming I'm not in the Data menu.
 
Upvote 0
use this bit
Destination:=Range(ActiveCell.Address)

when you select a range of Cells the ActiveCell is the most Top left hand corner of the selection
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

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