Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 9
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,365
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum by coding [email protected] New Users to Excel 1 February 27th 08 01:12 PM
How to fix the coding? Eric Excel Worksheet Functions 0 February 26th 08 03:38 AM
How to fix the coding? Eric Excel Worksheet Functions 4 June 20th 07 02:42 PM
coding maisy1 Excel Discussion (Misc queries) 1 August 6th 06 08:58 PM
coding Hardy Excel Discussion (Misc queries) 1 February 22nd 05 04:58 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"