ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replace blank cells with 0 (https://www.excelbanter.com/excel-programming/430027-replace-blank-cells-0-a.html)

scrabtree23[_3_]

Replace blank cells with 0
 
I need a code that will search a range (let's say A1:Z1) and will replace any
blank cells with a zero (0).

Gord Dibben

Replace blank cells with 0
 
If true blanks.............

Sub Zeros()
Dim rng As Range
Set rng = Nothing
On Error Resume Next 'just in case there are no blanks
Set rng = Range("A1:Z1").SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If rng Is Nothing Then
'do nothing
Else
rng.Value = 0
End If
End Sub


Gord Dibben MS Excel MVP

On Thu, 18 Jun 2009 07:32:01 -0700, scrabtree23
wrote:

I need a code that will search a range (let's say A1:Z1) and will replace any
blank cells with a zero (0).




All times are GMT +1. The time now is 12:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com