stuartgb100
Active Member
- Joined
- May 10, 2015
- Messages
- 322
- Office Version
- 2021
- Platform
- Windows
I have code that inserts a row if a hyperlink is found:
Sub If_Hyperlink_Insert_Row()
This uses a specified sheet & column.
I need to run this on all sheets in the activeworkbook (using For Each etc),
BUT the column containing the hyperlinks are different.
How do I find that column please ?
Thanks.
Sub If_Hyperlink_Insert_Row()
VBA Code:
Dim ws As Worksheet
Dim c, Rng As Range
Set ws = ActiveSheet
With ws
'Amend for required column
Set Rng = ws.Range("B2", ws.Cells(ws.Rows.Count, "B").End(xlUp))
For Each c In Rng
If c.Hyperlinks.Count > 0 Then ' has a hyperlink
Rows(c.Row + 1).Insert
Rows(c.Row + 1).RowHeight = 5
Set c = c.Offset(1, 0)
End If
Next
End With
End Sub
This uses a specified sheet & column.
I need to run this on all sheets in the activeworkbook (using For Each etc),
BUT the column containing the hyperlinks are different.
How do I find that column please ?
Thanks.