+ Reply to Thread
Results 1 to 13 of 13

Displaying wrong result on SUMIFS due to space in left

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Displaying wrong result on SUMIFS due to space in left

    Hi,

    I am facing a problem with the matching that is not producing the desired results.It might be due to the spaces in left hand side of each.The below formula I am using.
    =SUMIFS(DO!$Y$2:$Y$431,DO!$A$2:$A$431,SO!B2,DO!$T$2:$T$431,SO!A2,DO!$V$2:$V$431,SO!V2,DO!$X$2:$X$431,SO!AJ2)
    How can I revised the above said formula so that perfect match can be done which is currently is due to spaces.

    Thanking you in anticipation.

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,172

    Re: Displaying wrong result on SUMIFS due to space in left

    Try: =SUMIFS(DO!$Y$2:$Y$431,DO!$A$2:$A$431,"*"&SO!B2,DO!$T$2:$T$431,"*"&SO!A2,DO!$V$2:$V$431,"*"&SO!V2,DO!$X$2:$X$431,"*"&SO!AJ2)

  3. #3
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Displaying wrong result on SUMIFS due to space in left

    Quote Originally Posted by Phuocam View Post
    Try: =SUMIFS(DO!$Y$2:$Y$431,DO!$A$2:$A$431,"*"&SO!B2,DO!$T$2:$T$431,"*"&SO!A2,DO!$V$2:$V$431,"*"&SO!V2,DO!$X$2:$X$431,"*"&SO!AJ2)
    The above formula is perhaps not working.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Displaying wrong result on SUMIFS due to space in left

    Your data is a mess!

    You have leading space characters in some cells and some cells have as many as 173 space characters in them.

    In the SO sheet column AJ has many leading spaces and in the DO sheet column X has both leading spaces and cells full of spaces.

    I ran the macro at this link to remove them.

    The macro at that link will remove all leading/trailing
    and multiple interspersed char 32 space characters.
    It will also remove and/or convert char 160 non breaking
    spaces into standard char 32 space characters. It will
    work on text or numbers and the numbers will be
    converted to true numeric numbers.

    I use this macro dozens of times every single day!
    It's a real time saver.

    In addition, most of your data cells are formatted as TEXT. This includes numeric values.

    You should avoid applying type formats as much as possible.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Displaying wrong result on SUMIFS due to space in left

    I Have another

    Sub CLEAR()
    Dim cell As Range
    For Each cell In Selection
    cell.Value = Trim(cell.Value)
    Next
    End Sub
    Can you let me know,what is the difference in this(taking a lot of time in large data) and above Post 10 (as you said) and which one is better that can do perfect match ?

    The purpose of using above formula is to get the report in a separate sheet of Y column of SO & Y column of DO by matching :

    SO sheet - A,B,V,AJ and get in one column of Y output (Gross qty)
    DO sheet -A,T,V,X and get in another column of Y output (Gross qty)
    And getting the differences in third column.For this I am using Pivot table after using above formula

    Also suggest me if there is an alternative and best method.

    Thanx again for your kind support.
    Last edited by paradise2sr; 03-13-2016 at 10:46 PM.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Displaying wrong result on SUMIFS due to space in left

    I'm not a programmer so I can't tell you if one is better than the other.

    One is more extensive, that's for sure!

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: Displaying wrong result on SUMIFS due to space in left

    Where are the spaces?
    What does your data look like?
    upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Displaying wrong result on SUMIFS due to space in left

    Dear Sir,

    The data is exported from a software where it has more than 3000 data.The problem I have been facing is that of spaces in extreme left.It is clear that above mentioned formula I am using and on using trim to each it is creating an error.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Displaying wrong result on SUMIFS due to space in left

    Quote Originally Posted by paradise2sr View Post
    The data is exported from a software where it has more than 3000 data.
    You don't need to post the whole file with 1000's of rows of data.

    Just enough data to demonstrate the problem. 20 rows worth of data is plenty.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,684

    Re: Displaying wrong result on SUMIFS due to space in left

    As requested previously post a small sample Excel file.

  11. #11
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Displaying wrong result on SUMIFS due to space in left

    Hi,

    Pls find in attachment.The formula is in BA in SO Sheet.AJ of SO Sheet and 'X' column of DO sheet could not able to remove space by find & replace.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Displaying wrong result on SUMIFS due to space in left

    Dear Sir,
    Thanx for your reply.You mean to say

    Sub TrimALL()
       'David McRitchie 2000-07-03 mod 2000-08-16 2005-09-29 join.htm
       '-- http://www.mvps.org/dmcritchie/excel/join.htm#trimall
       ' - Optionally reenable improperly terminated Change Event macros
          Application.DisplayAlerts = True
          Application.EnableEvents = True   'should be part of Change Event macro
       If Application.Calculation = xlCalculationManual Then
          MsgBox "Calculation was OFF will be turned ON upon completion"
       End If
       Application.ScreenUpdating = False
       Application.Calculation = xlCalculationManual
       Dim cell As Range
       'Also Treat CHR 0160, as a space (CHR 032)
       Selection.Replace What:=Chr(160), Replacement:=Chr(32), _
         LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
       'Trim in Excel removes extra internal spaces, VBA does not
       On Error Resume Next   'in case no text cells in selection
       For Each cell In Intersect(Selection, _
          Selection.SpecialCells(xlConstants, xlTextValues))
         cell.Value = Application.Trim(cell.Value)
       Next cell
       On Error GoTo 0
       Application.Calculation = xlCalculationAutomatic
       Application.ScreenUpdating = True
    End Sub

  13. #13
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Displaying wrong result on SUMIFS due to space in left

    I kindly request the forum contributor to shift this post to group "Excel Programming / VBA / Macros" to get the vba expert opinion in this regard.

+ 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. [SOLVED] Code result wrong but formula correct result
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-11-2014, 12:26 PM
  2. Wrong result displaying using IFERROR-INDEX-MATCH-ROW Formula
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-16-2013, 01:03 PM
  3. SUMIFS Puzzle - Trying to avoid adding multiple SUMIFS to get valid result
    By haldavid in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-09-2013, 03:42 PM
  4. only pull from LEFT until a space
    By loner2003 in forum Excel General
    Replies: 4
    Last Post: 02-17-2011, 11:44 AM
  5. Pull left and right until space
    By maxthebear in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-11-2009, 10:40 AM
  6. excel result return wrong calcuation result
    By garyww in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-14-2006, 06:20 AM
  7. space left for future entry = #DIV/0!
    By clooney in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-24-2006, 09:46 AM

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