Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default locate shapes with specified text inside

Hi,

Using VBA, is there any way to locate the shape with specified text
inside in Excel?

thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default locate shapes with specified text inside

Sub DD()
Dim shp As Shape
Dim s As String
Dim TargetText As String
TargetText = "dog"
For Each shp In ActiveSheet.Shapes
On Error Resume Next
s = ""
s = shp.TextFrame.Characters.Text
On Error GoTo 0
If InStr(1, s, TargetText, vbTextCompare) Then
shp.Select
Exit For
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"lvcha.gouqizi" wrote in message
ups.com...
Hi,

Using VBA, is there any way to locate the shape with specified text
inside in Excel?

thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default locate shapes with specified text inside

Awesome! Thank you.

Could you please explain what's the meaning "GoTo 0" in your code? I
cannot find any line labeled with "0".

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default locate shapes with specified text inside

On Error Resume Next

suspends breaking on errors

On Error Goto 0

restores breaking on errors

These should be used in pairs and encompass an include as few statements as
necessary as they can mask real errors making debugging very difficult.

--
Regards,
Tom Ogilvy

"lvcha.gouqizi" wrote in message
ups.com...
Awesome! Thank you.

Could you please explain what's the meaning "GoTo 0" in your code? I
cannot find any line labeled with "0".



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default locate shapes with specified text inside

Thanks for explaining.

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
Calculate quantity of shapes inside another shape jlclyde Excel Discussion (Misc queries) 8 July 9th 11 06:00 AM
How do I locate cells that contain a certain text? EZ-XLS Excel Worksheet Functions 2 May 4th 09 09:41 PM
How to embed large number of variables in text inside a text box? Riva Chase Excel Discussion (Misc queries) 0 October 30th 07 01:42 AM
Using IF to locate specific text string value Metalmaiden Excel Programming 9 October 10th 04 12:26 AM
Text on shapes Jay[_11_] Excel Programming 0 September 5th 03 08:00 AM


All times are GMT +1. The time now is 06:50 PM.

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

About Us

"It's about Microsoft Excel"