![]() |
sum by coding without 0
hi
in the following program if there is no value in the cells a1 and b1 it returns 0 Public Sub Add2Cells() Range("C1").Value = Range("A1").Value + Range("B1").Value End Sub i need only the output if the both the cells have the data will you can tell me that |
sum by coding without 0
Public Sub Add2Cells()
If Not(IsEmpty(Range("A1"))) And _ Not(IsEmpty(Range("B1"))) Then Range("C1").Value = Range("A1").Value + Range("B1").Value End If End Sub Empty is not the same as zero, so either/both could actually hold zero and you'll get a result. Only if both have no entry in them will it be skipped. "kaja" wrote: hi in the following program if there is no value in the cells a1 and b1 it returns 0 Public Sub Add2Cells() Range("C1").Value = Range("A1").Value + Range("B1").Value End Sub i need only the output if the both the cells have the data will you can tell me that |
All times are GMT +1. The time now is 02:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com