Link to home
Start Free TrialLog in
Avatar of Milton Clark
Milton ClarkFlag for United States of America

asked on

Copying selected text (substring) from the ActiveCell

I want to write a VBA macro that can be invoked via hot-key combination which takes whatever portion of the text selected within the ActiveCell and copies it.  The macro will then take the copied text and paste it into another cell.

There appear to be two separate challenges:

1. I can't find code that will select and copy just the highlighted text from a cell.

2. If I go into a cell and select some text, it appears that hot-keys are not active, so I have no way to invoke the macro.

Any assistance is greatly appreciated.
Avatar of StephenJR
StephenJR
Flag of United Kingdom of Great Britain and Northern Ireland image

I don't think you can run macros whilst you are editing cells, so perhaps a different approach is needed. What are you trying to achieve?
Avatar of Milton Clark

ASKER

The group of users I'm working with spend hours of intensive data review and extraction.  From a single Description column, they typically have to grab 6-8 pieces of data out of one cell.  So they highlight portions of the text, copy it and paste it into another column.  

I want to simplify this process by highlighting the needed text, then using the appropriate macro to place it in the appropriate column, thereby eliminating the need to do: ... copy, navigate to target cell, paste, navigate back.

There are no usable markers or delimiters in the text ... it's all done by eyes-on-data and extracting it into the appropriate columns.

Does that help?
Just to clarify ... they highlight 6-8 pieces of data and paste each into the appropriate one of 8 columns.
"it's all done by eyes-on-data" - what are they looking for? Presumably there is some sort of pattern.
Avatar of Saqib Husain
I don't think you can directly do what you want. However if you are interested in a workaround then you can find at least two here

https://www.experts-exchange.com/questions/27044799/How-to-manipulate-text-within-an-excel-user-form.html
I know .. that's what I would hope for, too, but it's not the case.
So they have to eyeball it, highlight the piece of data they want copied, then move it to the proper target.

If I can't do this in native Excel because I can't run macros while in edit mode, could I do the equivalent in a userform?  Can I select and copy a portion of the text sitting in a text field, then use hot-key combos associated with a button (and associated macro) to move it to the target cell?

Thanks for your suggestions.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial