Hardcode Links - edit my code please?

S

Steph

Hi everyone. I have the code below to hardcode all cells with links to an
external workbook. I tried to add an if statement to display a msgbox if
the sheet has no external links, but I don't know the correct syntax. When
I run this, I get a type mismatch error on the line If rng = Empty Then.
Can anyone fix this? Thanks!

Sub Hardcode()

Dim ws As Worksheet
On Error Resume Next
Set rng = ActiveSheet.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If rng = Empty Then
MsgBox ("No Links in Sheets")
Else
For Each cell In rng
sform = cell.Formula
If InStr(sform, "[") Then
cell.Formula = cell.Value
End If
Next
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top