Fill in the blanks!

G

Guest

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.
 
G

Guest

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top