ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting 0 instead or blank cells (https://www.excelbanter.com/excel-programming/369467-getting-0-instead-blank-cells.html)

LoveCandle[_37_]

Getting 0 instead or blank cells
 

Hi everybody,

I have the following code which is working well on a single cell ,,but
it is showing an error message with multiple selection.


Code:
--------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Or Target.Column = 5 And Target.Row = 5 And Target.Row <= 11 Then
If Target = "" Then Target = 0
End If
End Sub
--------------------


Can You please summerize the range area (D5:E11) if that is possible
and make the code working properly with more than one cell.

Thank you,


--
LoveCandle
------------------------------------------------------------------------
LoveCandle's Profile: http://www.excelforum.com/member.php...o&userid=28612
View this thread: http://www.excelforum.com/showthread...hreadid=568578


LoveCandle[_38_]

Getting 0 instead or blank cells
 

After many tries I got the following code:


Code:
--------------------
Private Sub Worksheet_Change(ByVal Target As Range)

Dim MyRange As Range
Dim Cell As Range

Set MyRange = [D5:E11]
For Each Cell In MyRange
If Cell = "" Then Cell = 0
Next Cell

End Sub
--------------------


--
LoveCandle
------------------------------------------------------------------------
LoveCandle's Profile: http://www.excelforum.com/member.php...o&userid=28612
View this thread: http://www.excelforum.com/showthread...hreadid=568578



All times are GMT +1. The time now is 09:38 AM.

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