ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Substr Copy (https://www.excelbanter.com/excel-programming/293988-substr-copy.html)

DTHMTL

Substr Copy
 
Can you copy a substr of text using VBA?

123456ABC7890

I know that I can use this to copy the entire cell
Range("A1").Copy

I want to copy "ABC" and that is it. I tried using "substr" combinations
both they don't seem to work.

Thanks



Tom Ogilvy

Substr Copy
 
Do you actually need to get it into the clipboard?

If not

Range("B9").Value = Mid(Range("A1").Value,7,3)

if you need a string/text in the clipboard, see Chip Pearson's page on the
DataObject

http://www.cpearson.com/excel/clipboar.htm

--
Regards,
Tom Ogilvy

"DTHMTL" wrote in message
...
Can you copy a substr of text using VBA?

123456ABC7890

I know that I can use this to copy the entire cell
Range("A1").Copy

I want to copy "ABC" and that is it. I tried using "substr" combinations
both they don't seem to work.

Thanks





DTHMTL

Substr Copy
 
Sorry I mean "mid", I was thinking VFP


"DTHMTL" wrote in message
...
Can you copy a substr of text using VBA?

123456ABC7890

I know that I can use this to copy the entire cell
Range("A1").Copy

I want to copy "ABC" and that is it. I tried using "substr" combinations
both they don't seem to work.

Thanks





Frank Kabel

Substr Copy
 
Hi
is the value you want always at the same position?. If yes use Tom's
solution. If not you may provide some more details which substring you
want to get (that is what logic has to be applied)

--
Regards
Frank Kabel
Frankfurt, Germany


DTHMTL wrote:
Can you copy a substr of text using VBA?

123456ABC7890

I know that I can use this to copy the entire cell
Range("A1").Copy

I want to copy "ABC" and that is it. I tried using "substr"
combinations both they don't seem to work.

Thanks




All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com