![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: New York
Posts: 26
|
Hello All, i am trying to iterate through a range of cells and if the cell is empty i want to put in a zero. Any help would be appreciated.
Regards, Bill Mahoney |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
You can do it (at least) a couple of ways. The first (and easiest) is to select the range where you want to replace blanks with 0, and go to Edit-Replace, and type a 0 in the Replace With box, and check the Find Entire Cells only check box.
I'll post some VBA to do this in a few minutes. Here's some code that will work with the current selection (the currently selected cells/range). You can modify it to use a range that you specify. Code:
Sub FillBlanksWithZeros()
Dim cl As Range
For Each cl In Selection
If Trim(cl.Text) = vbNullString Then cl = 0
Next cl
End Sub
Russell -rh [ This Message was edited by: Russell Hauf on 2002-05-23 08:43 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: New York
Posts: 26
|
Thanks for the help.
Regards, Bill Mahoney |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|