target a shape

vba Chile
  • 15 years ago

    hi, im trying to create a hyperlink in excel to target a shape...


    any suggestion?

  • 15 years ago

    Hi mate,


    As far as I know you cant hyperlink to a shape directly so try fudging it with a Worksheet_SelectionChange event procedure.


    I dont know if this will work but try entering the name of the shpe in cell A1, and format it with blue underlined text, so it looks like a hyperlink. Right click on the sheet tab, select View Code, and paste this macro into the code module that appears:


     Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     If Not Intersect(Target, Range("A1")) Is Nothing Then
         On Error Resume Next
         Charts(Target.Value).Activate
         If Err.Number <> 0 Then
             MsgBox "No such shape exists.", vbCritical, _
                 "Shape Not Found"
         End If
         On Error GoTo 0
     End If
     End Sub

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Weeks of coding can save you hours of planning.”