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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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!
 
Upvote 0
Tried these today. Working beautifully. Destination:=Range(Activecell.Address was best for my project.

Thank you.
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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