+ Reply to Thread
Results 1 to 4 of 4

macro to create a hyperlink to another sheet, does not work on spaces or symbols

Hybrid View

  1. #1
    Registered User
    Join Date
    10-09-2014
    Location
    Longview, Texas
    MS-Off Ver
    2003
    Posts
    15

    macro to create a hyperlink to another sheet, does not work on spaces or symbols

    Any direction would be appreciated
    I have a userforum with macros that when a user types in the forum a code (such as "hm952336") and then clicks the add button, it creates a new row on one sheet with the code in Column C of that row, the code that is in column c is also a hyperlink to a newly created sheet in the same workbook.

      If zcode.Value <> "" Then 
        With Sheets("List").Select
          Sheets("List").Rows("2:2").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Rows("2:2").EntireRow.AutoFit
        Rows("2:2").Select
        
       
          Range("C2").Value = zcode
    
     Rows("2:2").Select
     Selection.Font.Name = "Arial"
            Selection.Font.Size = 12
        Selection.Font.Bold = False
            End With
    
            With Sheets("MCR (BLANK)").Select
                Sheets("MCR (BLANK)").Range("E15").Value = zcode.Value 'UL
    
    Sheets("MCR (BLANK)").Copy Before:=Sheets(3)
                   ActiveSheet.Name = zcode.Value
    Sheets("List").Range("C2").Hyperlinks.Add Anchor:=Sheets("List").Range("C2"), Address:="", SubAddress:=zcode.Value & "!A1", TextToDisplay:=zcode.Value
            End With
        Else
            MsgBox "UL Code required"
        End If
       Sheets("List").Select
    End Sub
    The issue is if the code has a space or a symbol (such as "hm9522336 hm9522337" or "hm9522336-hm9522338"), no hyperlink is created.
    How can I get the macro to create a hyperlink when a space or a symbol is in it.
    Here is the file:
    Attached Files Attached Files
    Last edited by Glitch_; 03-11-2015 at 04:45 PM.

  2. #2
    Registered User
    Join Date
    10-09-2014
    Location
    Longview, Texas
    MS-Off Ver
    2003
    Posts
    15

    Re: Getting a userform to accept spaces and symbols in creating a hyperlink.

    I also tried using a vb code, which would work except for the fact that I have to save it as a webpage, where only a macro can work.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Columns(3)) Is Nothing Then
            Call Sheetfinder(Target.Text)
        End If
    Cancel = True
    End Sub
    
    Sub Sheetfinder(ShtName As String)
        Sheets(ShtName).Select
    End Sub
    Last edited by Glitch_; 03-11-2015 at 04:28 PM.

  3. #3
    Registered User
    Join Date
    10-09-2014
    Location
    Longview, Texas
    MS-Off Ver
    2003
    Posts
    15

    Re: macro to create a hyperlink to another sheet, does not work on spaces or symbols

    For anyone reading this, with the same question, I was unable to make a hyperlink that will take a space or a dash. I found I used the vb code method,and the hyper link, and one group of people got the html version, the other group got the more interactive vb version.

  4. #4
    Forum Contributor
    Join Date
    12-24-2014
    Location
    little ole England
    MS-Off Ver
    2013
    Posts
    116

    Re: macro to create a hyperlink to another sheet, does not work on spaces or symbols

    just as an idea for the boiling pot

    as the sheet reference is only underlying the hyperlink, the visible hyperlink is only a title (which cannot have spaces and or certain characters contained as although use here is not as web link the default use would be.)

    what you could do in your create hyperlink macro is find and replace any spaces or dashes with an underscore in the hyperlink title

    this is the same principle excel uses when converting table to ranges using headers.

    not sure of the exact code to do this but is an option to solve your problem
    ◄Ŧя?μвŁ?►
    By Name & By Nature

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] A problem with creating a formula to substitute given symbols
    By Arty_1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-17-2014, 08:52 AM
  2. [SOLVED] help creating conditional formatting symbols using a formula
    By SEMMatt in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-22-2013, 10:27 AM
  3. format combobox in userform to accept dates
    By Brad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-02-2005, 06:20 PM
  4. format combobox in userform to accept dates
    By Brad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-02-2005, 06:17 PM
  5. [SOLVED] Creating custom chart legen pallettes/styles symbols
    By ChartDummy in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-19-2005, 12:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1