Find Hperlinks in column and copy entire row to new sheet

Bonacci8

New Member
Joined
Sep 15, 2008
Messages
26
I have a group of worksheets that I want to cycle through and look in column A for a hyperlink. If the cell has a hyper link in it I want to copy the entire row to the work sheet pTable. I have pieced the code below together as a first step to copy the just the link but it does not work with the .columns("A:A") porperty. It will work if I change it to .range but then I get every hyperlink on the sheet. Any Ideas? Thanks!


Sub Createprogramlist()
'finds hyperlinks and copies to pTable
Dim rCell As Range
Dim wSheet As Worksheet
Dim hLink As Long, cLink As Long
ThisWorkbook.Activate
For Each wSheet In Worksheets
If wSheet.Name <> "WebLaunch" And wSheet.Name <> "Tables" And wSheet.Name <> "pTable" Then
For hLink = 1 To wSheet.Columns("A:A").Hyperlinks.Count
'need to get hLink in column A
wSheet.Hyperlinks(hLink).Columns("A:A").Activate
wSheet.Hyperlinks(hLink).Columns("A:A").Copy _
Sheets("pTable").Cells(Rows.Count, 1).End(xlUp)(2, 1)
Next hLink
End If
Next wSheet
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this.

If you are re-running the program you will have to delete the "Copied Hyperlinks" sheet.

Code:
Option Explicit
Sub CopyHyperlinks()
    Dim WS As Worksheet
    Dim i As Integer
    Dim j As Integer
    j = 1
    Dim MyHyperlink As Hyperlink
    Set WS = Worksheets.Add(after:=Worksheets(Worksheets.Count))
    WS.Name = "Copied Hyperlinks"
    For i = 1 To (Worksheets.Count - 1)
        For Each MyHyperlink In Worksheets(i).Hyperlinks
            If Worksheets(i).Name <> "WebLaunch" And Worksheets(i).Name <> "Tables" And Worksheets(i).Name <> "pTable" Then
                If MyHyperlink.Range.Column = 1 Then
                    Worksheets(i).Rows(MyHyperlink.Range.Row).Copy
                    WS.Range("A" & j).PasteSpecial xlPasteAll
                    j = j + 1
                End If
            End If
        Next
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top