Beyond_avarice
Board Regular
- Joined
- Nov 13, 2012
- Messages
- 195
- Office Version
- 2007
- Platform
- Windows
Hey Gang,
I have put together the following script to help me delete links that are hidden within ConditionalFormats. This is to break those links that the "Edit Links" wizard can't do.
It "works" but I have found that on some of my workbooks; I have to go through a couple passes to eliminate everything. One example took me four passes and the last two passes involved a range I don't see in the first two passes. I suspect that there is something going on with the "AppliestTo.Address".
Hopefully will pick on what I haven't been able to detect as the issue. Thank you in advance.
I have put together the following script to help me delete links that are hidden within ConditionalFormats. This is to break those links that the "Edit Links" wizard can't do.
It "works" but I have found that on some of my workbooks; I have to go through a couple passes to eliminate everything. One example took me four passes and the last two passes involved a range I don't see in the first two passes. I suspect that there is something going on with the "AppliestTo.Address".
Hopefully will pick on what I haven't been able to detect as the issue. Thank you in advance.
Code:
Sub condFormLinkBreak3()
Dim cRule As String 'ConditionalFormat Rule
Dim cForm As Object 'ConditionalFormat Range applied to
Dim asw As Worksheet
Dim z as Single 'Counter for Txt detail
Application.ScreenUpdating = False
Set asw = ActiveSheet
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "TXT"
'
asw.Activate
z = 1
For Each cForm In ActiveSheet.Cells().FormatConditions
On Error Resume Next
'Debug.Print cForm.Formula1
'Debug.Print cForm.AppliesTo.Address
Sheets("TXT").Range("A" & z).Value = cForm.AppliesTo.Address
Sheets("TXT").Range("B" & z).Value = """" & cForm.Formula1 & """"
z = z + 1
On Error Resume Next
cRule = ""
cRule = cForm.Formula1
If InStr(1, cRule, "[") > 0 Then
asw.Range(cForm.AppliesTo.Address).FormatConditions(1).Delete 'delete anything with "["
End If
Next
Application.ScreenUpdating = True
End Sub