Results 1 to 10 of 10

Thread: Index Sheets with Shapes and Hyperlink

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Index Sheets with Shapes and Hyperlink

    Hello,

    What code would I have to create buttons or links (depending on 2 option buttons in userform) for sheets in the file.
    As an option want to write the name of new sheets in a textbox.

    Can you help me to start or show me how I can makeit?

    Thank you.

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 11-20-2023 at 04:02 PM.

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi TomyLee,

    Welcome to ExcelFox !!!

    Could you please elaborate little more ? Perhaps attach the workbook ?
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0
    Hello Admin,

    How can attach the workbook?

    In my userForm i have 2 option button (one to create hyperlinks to all my sheets, and second to create buttons with link to all my sheets). A textBox where I can write name of new sheet where will be all name of sheets - with hyperlink or buttons with name of sheet.
    Also have a comboBox where I choose number of columns for list (with name of sheet) or for buttons (with name of sheet).

  4. #4
    Junior Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Sheet index - different way

    In my userForm i have 2 option button (one to create hyperlinks to all my sheets, and second to create buttons with link to all my sheets). A textBox where I can write name of new sheet where will be all name of sheets - with hyperlink or buttons with name of sheet.
    Also have a comboBox where I choose number of columns for list (with name of sheet) or for buttons (with name of sheet).
    Attached Files Attached Files

  5. #5
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    If you click on Go Advanced, you could see 'manage attachments'. Click on the button and upload the file.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  6. #6
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Put this code in the userform module.

    Code:
    Option Base 1
    Private Sub CommandButton1_Click()
        
        Dim IdxShtName  As String
        Dim ShtName     As String
        Dim ShtNew      As Worksheet
        Dim rngHLink    As Range
        Dim shpHLink    As Shape
        Dim blnHLink    As Boolean
        Dim ColCount    As Long
        Dim ShtCount    As Long
        Dim r           As Long
        Dim c           As Long
        
        If Len(Me.TextBox1.Value) Then
            IdxShtName = Trim(Me.TextBox1.Value)
            
            On Error Resume Next
            Set ShtNew = Worksheets(IdxShtName)
            
            If Err.Number <> 0 Then
                Set ShtNew = Worksheets.Add
                ShtNew.Name = IdxShtName
            End If
            Err.Clear: On Error GoTo 0
            
            blnHLink = Me.OptionButton1.Value
            
            ColCount = Me.ComboBox1.List(Me.ComboBox1.ListIndex)
            If blnHLink Then
                ShtCount = Worksheets.Count
                With ShtNew
                    r = 1
                    For i = 1 To ShtCount
                        ShtName = Worksheets(i).Name
                        If ShtName <> IdxShtName Then
                            c = c + 1
                            Set rngHLink = .Cells(r, c)
                            rngHLink.Hyperlinks.Add rngHLink, Address:="", SubAddress:="'" & ShtName & "'!A1", TextToDisplay:=ShtName
                            If c Mod ColCount = 0 Then
                                r = r + 1: c = 0
                            End If
                        End If
                    Next
                End With
            Else
                ShtCount = Worksheets.Count
                With ShtNew
                    .Shapes.SelectAll
                    Selection.Delete
                    With .Cells(1).Resize(ShtCount, ColCount)
                        Debug.Print .Address
                        .Rows.RowHeight = 24
                        .Columns.ColumnWidth = 12
                    End With
                    r = 1
                    For i = 1 To ShtCount
                        ShtName = Worksheets(i).Name
                        If ShtName <> IdxShtName Then
                            c = c + 1
                            Set rngHLink = .Cells(r, c)
                            Set shpHLink = .Shapes.AddShape(5, rngHLink.Left + 2, rngHLink.Top + 2, rngHLink.Width - 4, rngHLink.Height - 4)
                            shpHLink.TextFrame2.TextRange.Text = ShtName
                            .Hyperlinks.Add shpHLink, Address:="", SubAddress:="'" & ShtName & "'!A1", TextToDisplay:=ShtName
                            If c Mod ColCount = 0 Then
                                r = r + 1: c = 0
                            End If
                        End If
                    Next
                End With
            End If
        End If
            
    End Sub
    
    Private Sub CommandButton2_Click()
        Unload Me
    End Sub
    
    Private Sub UserForm_Initialize()
        
        Dim i       As Long
        Dim c(10)   As Long
        
        For i = 1 To 10: c(i) = i: Next
        With Me.ComboBox1
            .Style = fmStyleDropDownList
            .List = c
            .ListIndex = 0
        End With
        
        Me.OptionButton1.Value = True
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  7. #7
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    TomyLee,

    Happy b'day. Have a great year ahead.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  8. #8
    Member
    Join Date
    Jul 2012
    Posts
    55
    Rep Power
    13
    Thank you for a great code.
    Last edited by Ingolf; 09-04-2012 at 08:37 PM.

  9. #9
    Junior Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0
    Hello Admin,

    Thanks for the wishes. Also thanks for the code, it's perfect for me.
    Thank you. I wish you an excellent day.

    TomyLee

  10. #10
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Tomy/Ingolf

    Thanks for the feedback.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Calling UDFs by Hyperlink
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 0
    Last Post: 06-06-2013, 07:53 PM
  2. Change Hyperlink Screentip
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 0
    Last Post: 06-06-2013, 07:53 PM
  3. Did You Know? :: Formatting Shapes in Powerpoint & Excel: Setting Defaults
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-19-2013, 08:35 AM
  4. SharePoint Hyperlink issue
    By PeteRooney in forum Excel Help
    Replies: 0
    Last Post: 10-30-2012, 03:25 PM
  5. Align Shapes (Charts) On ActiveWorksheet
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 1
    Last Post: 05-14-2012, 03:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •