Text-to-Column Macro / New Destination Cells

Tommy Random

New Member
Joined
Dec 12, 2009
Messages
22
User copies and pastes data (as text) to the next unused row on a worksheet. Data/Text-to-Column works fine. Later the user updates the worksheet in the same manner, and the new data occupies a new location further on down in the worksheet.

As part of a longer macro, I wish to include the code to convert text to columns at the location of the active cell, where the new data has just been pasted. The code I get when I use the macro recorder includes the destination for the active cell at the point the macro was recorded. (If the user invokes the recorded macro, useful data would be overwritten.) So, how do I work it so the text-to-column conversion is applied at the location of the current active cell?

Here is the relevant portion of the recorded macro code, problem element in Bold:

Selection.TextToColumns Destination:=Range("A10219"), DataType:= _

I am thankful for any help.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,887
So, how do I work it so the text-to-column conversion is applied at the location of the current active cell?

Hi Tommy
Welcome to the board

Try:

Code:
Selection.TextToColumns Destination:=ActiveCell, DataType:=
 

snowblizz

Well-known Member
Joined
Mar 16, 2009
Messages
1,123
Try :
Destination:=Range(Activecell.Address)

it will take the address of the currently selected cell as the range.

Edit: Or more easily as PGC notes!
 

Tommy Random

New Member
Joined
Dec 12, 2009
Messages
22
Tried these today. Working beautifully. Destination:=Range(Activecell.Address was best for my project.

Thank you.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,108
Messages
5,857,431
Members
431,879
Latest member
KiwDaWabbit

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