Problem with the Div / 0 replacement loop

Palucci

Banned user
Joined
Sep 15, 2021
Messages
138
Office Version
  1. 365
Platform
  1. Windows
Hey Guys!
I have two loops that replace the result of Div / 0 with an empty cell, the problem is that the first loop works and the second one doesn't, there is no error, but only one table has a result
Rich (BB code):
Dim MyRange As Range
With wbMe.Sheets("page3").Range("B30:D44")
        .EntireRow.Hidden = False
        On Error Resume Next
        Set MyRange = .SpecialCells(xlConstants, xlErrors)
        On Error GoTo 0
        If Not MyRange Is Nothing Then
            MyRange.ClearContents
         End If
With wbMe.Sheets("page3").Range("B76:K89")
        .EntireRow.Hidden = False
        On Error Resume Next
        Set MyRange = .SpecialCells(xlConstants, xlErrors)
        On Error GoTo 0
        If Not MyRange Is Nothing Then
            MyRange.ClearContents
        End If
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
What happens if you remove this line On Error Resume Next from the code looking at B76:K89
 
Upvote 0
Hi Fluff i got error ""No cells found" 1004 here
Rich (BB code):
Set MyRange = .SpecialCells(xlConstants, xlErrors)
But be honest there are many position with Div/0 here my code
Rich (BB code):
Dim MyRange As Range
With wbMe.Sheets("page3").Range("B30:D44")
        .EntireRow.Hidden = False
        On Error Resume Next
        Set MyRange = .SpecialCells(xlConstants, xlErrors)
        On Error GoTo 0
        If Not MyRange Is Nothing Then
            MyRange.ClearContents
         End If
With wbMe.Sheets("page3").Range("B76:K89")
        .EntireRow.Hidden = False
        Set MyRange = .SpecialCells(xlConstants, xlErrors)
        On Error GoTo 0
        If Not MyRange Is Nothing Then
            MyRange.ClearContents
        End If
 
Upvote 0
Hi,​
with SpecialCells just search formulas rather than constants …​
 
Upvote 0
Its resolved guys ! Thanks for help i changed to
Rich (BB code):
With wbMe.Sheets("page3").Range("B76:K89")
        .EntireRow.Hidden = False
        Set MyRange = SpecialCells(xlCellTypeFormulas, xlErrors)
        On Error GoTo 0
        If Not MyRange Is Nothing Then
            MyRange.ClearContents
        End If
 
Upvote 0
You've been warned about this repeatedly:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: VBA Problem with the Div / 0 replacement loop
If you have posted the question at more places, please provide links to those as well.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,913
Members
449,093
Latest member
dbomb1414

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