ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill in the blanks! (https://www.excelbanter.com/excel-programming/354890-fill-blanks.html)

Bhupinder Rayat

Fill in the blanks!
 
Hi All,

I have a range of cells (i.e. A1:D5), some cells contain values and others
are blank cells.

I want to create a piece of code that checks each cell in the range. If a
cell is blank is blank then insert a 0, and if a cell contains a value then
ignore it and move onto the next cell.

Can anyone help at all?

Many thanks,

Pinda.

Gary''s Student

Fill in the blanks!
 
This runs off any range you select:

Sub Macro1()
Dim r As Range
For Each r In Selection
If IsEmpty(r.Value) Then
r.Value = 0
End If
Next
End Sub


--
Gary''s Student


"Bhupinder Rayat" wrote:

Hi All,

I have a range of cells (i.e. A1:D5), some cells contain values and others
are blank cells.

I want to create a piece of code that checks each cell in the range. If a
cell is blank is blank then insert a 0, and if a cell contains a value then
ignore it and move onto the next cell.

Can anyone help at all?

Many thanks,

Pinda.


Bhupinder Rayat

Fill in the blanks!
 
works a treat, thank you

Apologies for the repeated thread, I wasn't getting the prompt box to say my
message had been posted.

Thanks again,

Pinda.

"Gary''s Student" wrote:

This runs off any range you select:

Sub Macro1()
Dim r As Range
For Each r In Selection
If IsEmpty(r.Value) Then
r.Value = 0
End If
Next
End Sub


--
Gary''s Student


"Bhupinder Rayat" wrote:

Hi All,

I have a range of cells (i.e. A1:D5), some cells contain values and others
are blank cells.

I want to create a piece of code that checks each cell in the range. If a
cell is blank is blank then insert a 0, and if a cell contains a value then
ignore it and move onto the next cell.

Can anyone help at all?

Many thanks,

Pinda.



All times are GMT +1. The time now is 11:27 AM.

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