+ Reply to Thread
Results 1 to 6 of 6

Getting the sum of two products, but leave blank if blank.

  1. #1
    Registered User
    Join Date
    01-12-2015
    Location
    Seattle, WA, USA
    MS-Off Ver
    2013
    Posts
    19

    Talking Getting the sum of two products, but leave blank if blank.

    I'm in the process of trying get the sum of two products; inventory items X quantity.

    But if the cell is left blank, then the cell ought to be blank, without any errors.

    For example:

    Function LineTotal(b As Currency, c As Integer, f As Currency, g As Integer)

    If c > 0 "and" g > 0 Then
    LineTotal = (c * b) + (g * f)
    ElseIf c > 0 "and" g = "" Then
    LineTotal = (c * b)
    ElseIf c = "" "and" g > 0 Then
    LineTotal = (g * f)
    ElseIf c = "" "and" g = "" Then
    LineTotal = ""
    End If


    End Function



    Thanks,

    Cris

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Getting the sum of two products, but leave blank if blank.

    Hello Talk_4,
    Not sure that you need a macro to do this....

    Here a formula you can use :
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Getting the sum of two products, but leave blank if blank.

    If you want a macro, here's a suggestion`:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-12-2015
    Location
    Seattle, WA, USA
    MS-Off Ver
    2013
    Posts
    19

    Re: Getting the sum of two products, but leave blank if blank.

    This is what I'm trying to avoid.

    LineTotalError.PNG

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Getting the sum of two products, but leave blank if blank.

    Please attach a sample file remove sensitive data if any
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  6. #6
    Registered User
    Join Date
    01-12-2015
    Location
    Seattle, WA, USA
    MS-Off Ver
    2013
    Posts
    19

    Post Re: Getting the sum of two products, but leave blank if blank.

    ExcelForum_OverStock_RG.xls

    Here is my file.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 09-20-2013, 01:43 PM
  2. Replies: 5
    Last Post: 05-29-2013, 12:27 AM
  3. [SOLVED] Simple pull exact text from cell, if blank it pulls up a 0. How to leave it as blank?
    By sharpmel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-30-2012, 02:20 PM
  4. Replies: 2
    Last Post: 06-21-2012, 04:51 PM
  5. Replies: 4
    Last Post: 07-15-2008, 01:42 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1