Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Jan 2009
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    copying and pasting a hyperlink in VBA Excel 2003

    Need some help tweaking the VBA. This code works fine other than I am copying a hyperlink in line "Cells(2, 3).Value = Cells(rw, 7).Value"
    While it copies the text fine, it doesn't copy the hyperlink. Is there a way to copy the hyperlink?

    Thanks,

    Sub coverletter()

    Dim shInv As Worksheet

    Set shInv = ThisWorkbook.Sheets("Cover Letter")
    If Selection.Column <> 6 Or Selection.Value = "" Then
    MsgBox "There is nothing to export!" & Chr(10) & "Select a cell with data from column F," & Chr(10) & "and try again"
    Exit Sub
    End If
    rw = Selection.Row
    With shInv
    .Cells(2, 3).Value = Cells(rw, 7).Value
    .Cells(3, 3).Value = Cells(rw, 9).Value
    .Cells(3, 10).Value = Cells(rw, 8).Value
    .Cells(4, 3).Value = Cells(rw, 10).Value
    .Cells(4, 9).Value = Cells(rw, 15)

    End With
    Cells(rw, "F").Select
    shInv.Select
    End Sub

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,895
    Thanks
    0
    Thanked 85 Times in 81 Posts
    Perhaps change it to:
    Code:
    Cells(rw, 7).Copy Destination:=.Cells(2, 3)
    Regards,
    Rory
    Microsoft MVP - Excel.

Posting Permissions

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