ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make all empty cells in columns = 0 (https://www.excelbanter.com/excel-programming/304682-make-all-empty-cells-columns-%3D-0-a.html)

poppy

Make all empty cells in columns = 0
 
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
-------------------


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

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


Frank Kabel

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/

.


poppy

Make all empty cells in columns = 0
 
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

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


poppy

Make all empty cells in columns = 0
 
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

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



All times are GMT +1. The time now is 03:37 AM.

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