pasting right hand chars copied from XL

User avatar
stuck
Panoramic Lounger
Posts: 8176
Joined: 25 Jan 2010, 09:09
Location: retirement

pasting right hand chars copied from XL

Post by stuck »

In Word VBA the line:

Code: Select all

ActiveDocument.Bookmarks("bmkNUM").Range.Text = xlWsh.Range("A1").Text
puts the contents of cell A1 of an XL workbook into my document at the designated bookmark but cell A1 holds a string and I only want the right hand end of it.

Please can I have some pointers to how I can extract just the bit of cell A1 I want?

Thanks,

Ken

User avatar
HansV
Administrator
Posts: 78481
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: pasting right hand chars copied from XL

Post by HansV »

If you want to extract, for example, the last 3 characters from the text in cell A1, you can use

ActiveDocument.Bookmarks("bmkNUM").Range.Text = Right(xlWsh.Range("A1").Text, 3)
Best wishes,
Hans

User avatar
stuck
Panoramic Lounger
Posts: 8176
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: pasting right hand chars copied from XL

Post by stuck »

Ah, I see! Putting Right() around the range was the one thing I didn't try.

Thanks,

Ken