+ Reply to Thread
Results 1 to 6 of 6

Thread: How to hyperlink cell value to userform created worksheet?

  1. #1
    Registered User
    Join Date
    02-17-2011
    Location
    NC
    MS-Off Ver
    Excel 2003
    Posts
    8

    Lightbulb How to hyperlink cell value to userform created worksheet?

    I have created a user form that will create a new sheet to match the EmployeeName entered and then on a different sheet copy that EmployeeName to a cell. I would like the code to make the new cell hyperlink to the sheet with the same name. Below is a copy of my existing code:

    'Based on user selection from form
        If Specialty = True Then
    'unhides template and then copies to a new sheet
            Sheets("Specialty").Visible = True
            Sheets("Specialty").Copy Before:=Sheets("Specialty")
            Sheets("Specialty (2)").Select
            Range("G1").Value = EmployeeNumber.Value
            Range("B2").Value = StartDate.Value
    'renames new sheet to match the Employee Name entered on the user form
            Sheets("Specialty (2)").Select
            Sheets("Specialty (2)").Name = EmployeeName
            Sheets("Specialty").Select
            Sheets("Specialty").Visible = False
    'selects snapshot worksheet and copies the employee name into a cell
            Sheets("SnapShot").Select
                Range("Data3").Select
                Selection.EntireRow.Hidden = False
                Range("Data3").Select
                Selection.Copy
                ActiveCell.Offset(1).EntireRow.Insert
                ActiveCell.Offset(1, 0).Select
                'paste the copied data in there
                Range("reHide3").Select
                ActiveCell.Offset(1, 0).Select
                 
    'This is where I need help 
    'I need this new cell value to hyperlink to the sheet that was just created above that has the same name.  
          
                ActiveCell.Value = EmployeeName
                           
                Range("Data3").Select
                Selection.EntireRow.Hidden = True
                Application.CutCopyMode = False
                Range("C35").Select
                
            Sheets("Welcome").Select
            Unload Me
        End If
    I hope what I am asking for is clear. Any help would be greatly appreciated.



    Thanks.
    Last edited by jwichern1; 02-25-2011 at 10:40 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: How to hyperlink cell value to userform created worksheet?

    ActiveCell.Formula = "=HYPERLINK(""#" & EmployeeName & "!A1"",""" & EmployeeName & """)"
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    02-17-2011
    Location
    NC
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to hyperlink cell value to userform created worksheet?

    Andy,

    Thank you for your quick response. However, I am getting an error message saying "Reference not valid" when I click the link. Do you have any suggestions on how to correct this?

    Edit - It appears the issue is caused because the name entered has a first and last name with a <space> between them. Is there a fix for this?

    Thank you,
    John
    Last edited by jwichern1; 02-25-2011 at 10:20 AM.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: How to hyperlink cell value to userform created worksheet?

    wrap the sheet name in single quotes.

    ActiveCell.Formula = "=HYPERLINK(""#'" & EmployeeName & "'!A1"",""" & EmployeeName & """)"
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    02-17-2011
    Location
    NC
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to hyperlink cell value to userform created worksheet?

    That's perfect. Thank you very much for your help.

  6. #6
    Registered User
    Join Date
    06-10-2011
    Location
    United States, New York
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: How to hyperlink cell value to worksheet with the same name?

    I am attempting to have Excel VBA identify the name in the active cell and hyperlink that cell to a sheet within the same workbook that has the same name as the cell? Is this possible? If so could some one walk me through how to write such code?

    Thx, J

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0