Results 1 to 20 of 31

Thread: Get Underlying Hyperlinks Out of Friendly Names

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    VBAX Mentor XL-Dennis's Avatar
    Joined
    May 2004
    Location
    ?stersund, Sweden
    Posts
    499
    Location
    Hi all :hi

    Unlike other boards I like to see that we also include error-handling in the provided solutions, especially when they are supposed to be used by less skilled user.

    Therefore I made the following add-ons:

    Option Explicit
    Sub Do_It()
    Dim rnSource As Range, rnStart As Range, rnTarget as Range
    If ActiveSheet.ProtectContents = False Then
        If TypeName(Selection) = "Range" Then
            With Selection
                If .Columns.Count <> 1 Then
                    MsgBox "Please make sure that the selection only contains one column.", vbInformation
                    GoTo ExitHere
                ElseIf .Areas.Count <> 1 Then
                    MsgBox "Please make sure that the selection only covers one area.", vbInformation
                    GoTo ExitHere
                Else
                    Set rnSource = Selection
                End If
            End With
        Else
            MsgBox "You need to select a range before executing this procedure.", vbExclamation
            GoTo ExitHere
        End If
    Else
        MsgBox "You need to unprotect the worksheet before executing this procedure.", vbExclamation
        GoTo ExitHere
    End If
    On Error Resume Next
    Set rnStart = Application.InputBox( _
    Prompt:="Please select the first cell in the target range:", _
    Title:="Select targetrange", _
    Type:=8)
    On Error GoTo 0
    If rnStart Is Nothing Then
        GoTo ExitHere
    Else
        Set rnTarget = rnStart.Resize(rnSource.Rows.Count, 1)
        Transfer rnSource, rnTarget
    End If
    ExitHere:
    Exit Sub
    End Sub
    
    Private Sub Transfer(ByRef rng As Range, ByRef Target As Range)
    Application.ScreenUpdating = False
    rng.Copy
    Target.PasteSpecial (xlPasteAll)
    With rng
        .Hyperlinks.Delete
    End With
    With Application
        .CutCopyMode = False
        .ScreenUpdating = True
    End With
    End Sub
    Kind regards,
    Dennis
    Last edited by XL-Dennis; 05-27-2004 at 04:06 AM.
    Kind regards,
    Dennis

    ExcelKB | .NET & Excel | 2nd edition PED


Posting Permissions

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