Make all empty cells in columns = 0

  • Thread starter Thread starter poppy
  • Start date Start date
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
 
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
 
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
 
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
 

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

Back
Top