Make all empty cells in columns = 0

P

poppy

Hi

How would I change or modify this code to look for all empty cell an
make them equal to 0.

eg

From this:

A B
2


To look like this

A B
2 0


Code
-------------------
lastrow = Cells(Rows.Count, "A").End(xlUp).Row

For i = 3 To 31 Step 2
For j = 3 To lastrow Step 1
With Cells((j), (i))
If j = Val("") Then ' or j < 0 Then
Cells(j) = 0
End If
End With
Next
Nex
 
F

Frank Kabel

Hi
try:

For i = 3 To 31 Step 2
For j = 3 To lastrow Step 1
With Cells(j, i)
If .value="" Then ' or j < 0 Then
.value = 0
End If
End With
Next
Next
 
P

poppy

Hi Frank

You know it does something funny. It does change all the empty column
to 0, but then it makes ALL my column values that irrittating "#VALUE!


I dont know what's going on


Kind Regard
 
P

poppy

Hi

About that last message

I left something out that was why I was getting that funny value.
managed to fix it but now it just says type mismatch with if statemen
containing the .value statement.


Kind Regard
 
Top