Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
rj
 
Posts: n/a
Default Copying text from a shape

Hi All,

Is there any way I can copy the text from a shape in a worksheet to a
cell on the same worksheet?
Im looking for a formula, a macro would be last resort.

Thanx in advance..

  #2   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Copying text from a shape

Hi rj,
As far as I know there is no formula that can do that.
If you select the shape containing the required text then run the
following macro it will show an inputbox asking you to select the
destination cell.
Then, after you click OK, that shape's text will appear in the
destination cell you selected.
You will have to make sure that when you select the shape that the
flashing I-bar does not appear inside the shape. Macros can't be run
while Excel is in edit mode.
So, click the shapes border, not its interior, then run this macro...

Public Sub ShapeCaptionToCell()
Dim strShpText As String
Dim rngDestination As Range
On Error GoTo NOTSHAPE
strShpText = Application.selection.Caption
Set rngDestination = Application.InputBox(prompt:="Select the
destination cell", Type:=8)
rngDestination.Value = strShpText
NOTSHAPE:
End Sub

To get the code in place...
1) Copy
2) press Alt + F11 to get into the VBA Editor
3) Go InsertModule
4) Paste the code into the new module

Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Copying text from a shape

Hi rj,
So that you don't have any problems caused by the break in the 6th
line, copy and paste this version...

Public Sub ShapeCaptionToCell()
Dim strShpText As String
Dim rngDestination As Range
On Error GoTo NOTSHAPE
strShpText = Application.selection.Caption
Set rngDestination = Application.InputBox _
(prompt:="Select the destination cell", _
Type:=8)
rngDestination.Value = strShpText
NOTSHAPE:
End Sub

Also, when you select the destination range it can be bigger than one
cell and can even be a non-contiguous range (selected while holding
down Ctrl).

Ken Johnson

  #4   Report Post  
Posted to microsoft.public.excel.misc
rj
 
Posts: n/a
Default Copying text from a shape

Thanx Ken :)

  #5   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Copying text from a shape

You're welcome rj.
Thanks for the feedback.
Ken Johnson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
How change dimensions of data label text box in pie chart? Gouden Willem Charts and Charting in Excel 3 March 7th 06 12:11 PM
Copying text to password boxes neeraj Excel Discussion (Misc queries) 3 September 21st 05 06:54 PM
Sort or Filter option? Mcobra41 Excel Worksheet Functions 3 February 23rd 05 07:22 PM
Issue with copying Text. David Excel Discussion (Misc queries) 2 December 17th 04 12:39 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"