VBA Extrair Caminho de Links - Excel

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Sub ExtrairCaminhosHyperlink()

Dim ws As Worksheet
Dim rngSource As Range
Dim rngTarget As Range
Dim cell As Range
Dim hyperlinkAddress As String

' Defina a planilha de origem (onde estão os hyperlinks)


Set ws = ThisWorkbook.Sheets("NomeDaSuaPlanilha")

' Defina o intervalo de células com os hyperlinks


Set rngSource = ws.Range("A1:A" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)

' Defina o intervalo de células para os caminhos extraídos


Set rngTarget = ws.Range("B1:B" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)

' Percorra cada célula com hyperlink e extraia o caminho


For Each cell In rngSource
If cell.Hyperlinks.Count > 0 Then
hyperlinkAddress = cell.Hyperlinks(1).Address
rngTarget.Value = hyperlinkAddress
Set rngTarget = rngTarget.Offset(1, 0)
End If
Next cell
End Sub

You might also like