Skip code if no blanks are found

Justplainj

New Member
Joined
Apr 15, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have the following code to find blank cells in a specific range (Column A and Row 1 will never have blank cells but the rest might)
After finding blanks it must replace it with a zero.
However if it does not find blank cells it must continue with the rest of the VBA code I have.

VBA Code:
    Sheets("Active Dev").Select
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.FormulaR1C1 = "0"

How do I allow the code to continue if no blanks are found?
Note: This is a small part of several sheets that is checked with the same VBA code, before the sheets are copied and pasted into one sheet.

Thanks in advance.
J
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Justplainj

New Member
Joined
Apr 15, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Solved.

I amended the code to the following.

VBA Code:
On Error Resume Next
    Sheets("Active Dev").Select
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeBlanks).Value = "0"

Thanks
 
Solution

Forum statistics

Threads
1,147,958
Messages
5,744,043
Members
423,843
Latest member
alex2022

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
Top