+ Reply to Thread
Results 1 to 5 of 5

Hyperlink issue on excel userform

  1. #1
    Registered User
    Join Date
    07-13-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    18

    Hyperlink issue on excel userform

    Hi guys

    I have put together a basic reports userform, and have been tasked with including a hyperlink option to upload engineering reports.
    I havefound a nice bit of code which I have adapted to suit my needs, but it only inserts the hyperlink in an Active cell.
    Try as I might, I cat get it to insert the hyperlink into iRow, 8, which is the cell on the worksheet it would be required.

    The hyperlink code I have been working in is below.

    To find the relevant report-

    Private Sub CommandButton1_Click()


    Dim FileName As String

    FileName = Application.GetOpenFilename()
    TextBox1.Value = FileName
    TextBox1.SetFocus

    End Sub

    Then to add the hyperlink-

    Private Sub CommandButton2_Click()
    'OK - ADD HYPERLINK TO ACTIVE CELL

    With ActiveCell
    If Not .Hyperlinks Is Nothing Then
    .Hyperlinks.Add Anchor:=ActiveCell, Address:=TextBox1.Text
    End If
    End With

    End Sub

    Any help much appreciated

    Maggie

  2. #2
    Registered User
    Join Date
    05-11-2015
    Location
    Chicago, IL
    MS-Off Ver
    2013
    Posts
    27

    Re: Hyperlink issue on excel userform

    It's easy to get confused by
    Please Login or Register  to view this content.
    because it seems "magical", but it is actually just a Range!

    To insert your hyperlink to a different destination, you can define that destination like I do below with the variable rngTargetCell.

    Please Login or Register  to view this content.
    VBA demystified:
    HTML Code: 

  3. #3
    Registered User
    Join Date
    07-13-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    18

    Re: Hyperlink issue on excel userform

    Hi,thanks for your help, but having played around with it, still can't get a way to add it to correct row on worksheet.

    My code uses the iRow method to insert data to a fresh line, so not sure how to get the hyperlink to insert into the correct cell with all the other new data on the same row.

    Code for the form as it runs without hyperlinks attached:
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-11-2015
    Location
    Chicago, IL
    MS-Off Ver
    2013
    Posts
    27

    Re: Hyperlink issue on excel userform

    Cool -- so
    Please Login or Register  to view this content.
    is an Integer that represents the last-occupied row in the Data sheet. (This is a very common VBA pattern, by the way -- determining the last-occupied row on a Worksheet is a cornerstone of VBA programming.)

    This should add links as needed:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-13-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    18

    Re: Hyperlink issue on excel userform

    I cant thank you enough-I tested the bit of code you sent, and it all works perfectly! Ive only been using VB a month or so, but the help I get off here rom people who dont criticize my efforts makes it all worth while.
    Again, many thanks for your help today.

    Maggie

+ 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. Excel Web Hyperlink Issue
    By karrde97 in forum Excel General
    Replies: 3
    Last Post: 09-06-2013, 07:41 PM
  2. Excel VBA in a userform that create a hyperlink into a specific cell location
    By mikeflatley01 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-19-2013, 08:04 PM
  3. [SOLVED] excel 2007 hyperlink issue
    By CityInspector in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-19-2012, 01:15 PM
  4. Hyperlink issue with Excel 2007
    By gnkurup in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-10-2011, 11:42 AM
  5. Excel hyperlink download issue
    By space108th in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-23-2009, 02:37 PM
  6. excel to ie 7 hyperlink issue
    By hmarcel in forum Excel General
    Replies: 0
    Last Post: 05-03-2009, 10:57 AM
  7. Having an issue with Excel Hyperlink
    By Jakobi in forum Excel General
    Replies: 0
    Last Post: 08-02-2007, 09:29 AM
  8. Excel hyperlink issue
    By polerz in forum Excel General
    Replies: 0
    Last Post: 01-14-2007, 06:20 PM

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