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.
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,791
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.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,655
Messages
5,512,645
Members
408,908
Latest member
ShaneMorr

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top