View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Make all empty cells in columns = 0

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


-----Original Message-----
Hi

How would I change or modify this code to look for all

empty cell and
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
Next
--------------------


I have tried different things but keep them this "#VALUE!"


---
Message posted from http://www.ExcelForum.com/

.