Can someone help me understand why my sumifs isn't working in vba?











up vote
0
down vote

favorite












I'm trying to code the following in VBA:



=SUMIFS(N2:N29,D2:D29,IF(COUNTIF(D2:D29,A36)=0,"*","="&A36),C2:C29,IF(COUNTIF(C2:C29,B36)=0,"*","="&B36),E2:E29,IF(COUNTIF(E2:E29,C36)=0,"*","="&C36),F2:F29,IF(COUNTIF(F2:F29,D36)=0,"*","="&D36))


The nested If and Countif are in there so that the Sumif ignores any condition that isn't required by the user (the user inputs A:B36), but still sums cells that meet all the remaining conditions.



I've written the following in vb (with criterias 1-3 determined in the same way):



If Application.WorksheetFunction.CountIf(Worksheets("Benchmark").Range("V" & i), Box4.Value) = 0 Then
criteria4 = "*"
Else
criteria4 = "=" & Box4.Value
End If

If criteria1 = "*" And criteria2 = "*" And criteria3 = "*" And criteria4 = "*" Then
dummy = 0
Else
dummy = Application.WorksheetFunction.SumIfs(Worksheets("Benchmark").Range("H" & i), Worksheets("Benchmark").Range("S" & i), criteria1, Worksheets("Benchmark") _
.Range("R" & i), criteria2, Worksheets("Benchmark").Range("C" & i), criteria3, Worksheets("Benchmark").Range("V" & i), criteria4)


but what is happening is that the sumifs is summing all cells that meet at least one of the conditions supplied, rather than all of them...



Does anyone know where I'm going wrong? Appreciate that this is a bit of a convoluted question, hope it makes sense...



Edit: To add context, the purpose of this code is to loop through a range, and find cells that meet criteria supplied by the user. However, if the user opts to supply certain criteria but not others, then those criteria not supplied are ignored. I've used a sumifs because my understanding is that the function will sum all cells that meet the set of criteria supplied. I can then say, if sumifs>0 then cell meets criteria supplied by the user










share|improve this question




















  • 1




    Just checking: Have you tried using the formula without the VBA to check that the formula itself is working as expected?
    – Mistella
    Nov 19 at 12:42










  • Hi Mistella - Thanks for replying. Yes I have, it works fine in the spreadsheet...
    – Jerbs
    Nov 19 at 12:44










  • Where are you setting i? Is it a single number, or part of a range (e.g. "3:H10")?
    – Chronocidal
    Nov 19 at 12:46










  • So what I've posted is nested within a for loop, for i = 2 to LastRow
    – Jerbs
    Nov 19 at 12:48












  • Also - your Excel and VBA formula are pointing to completely different columns? Is this deliberate, or have you mis-posted one of them?
    – Chronocidal
    Nov 19 at 12:52















up vote
0
down vote

favorite












I'm trying to code the following in VBA:



=SUMIFS(N2:N29,D2:D29,IF(COUNTIF(D2:D29,A36)=0,"*","="&A36),C2:C29,IF(COUNTIF(C2:C29,B36)=0,"*","="&B36),E2:E29,IF(COUNTIF(E2:E29,C36)=0,"*","="&C36),F2:F29,IF(COUNTIF(F2:F29,D36)=0,"*","="&D36))


The nested If and Countif are in there so that the Sumif ignores any condition that isn't required by the user (the user inputs A:B36), but still sums cells that meet all the remaining conditions.



I've written the following in vb (with criterias 1-3 determined in the same way):



If Application.WorksheetFunction.CountIf(Worksheets("Benchmark").Range("V" & i), Box4.Value) = 0 Then
criteria4 = "*"
Else
criteria4 = "=" & Box4.Value
End If

If criteria1 = "*" And criteria2 = "*" And criteria3 = "*" And criteria4 = "*" Then
dummy = 0
Else
dummy = Application.WorksheetFunction.SumIfs(Worksheets("Benchmark").Range("H" & i), Worksheets("Benchmark").Range("S" & i), criteria1, Worksheets("Benchmark") _
.Range("R" & i), criteria2, Worksheets("Benchmark").Range("C" & i), criteria3, Worksheets("Benchmark").Range("V" & i), criteria4)


but what is happening is that the sumifs is summing all cells that meet at least one of the conditions supplied, rather than all of them...



Does anyone know where I'm going wrong? Appreciate that this is a bit of a convoluted question, hope it makes sense...



Edit: To add context, the purpose of this code is to loop through a range, and find cells that meet criteria supplied by the user. However, if the user opts to supply certain criteria but not others, then those criteria not supplied are ignored. I've used a sumifs because my understanding is that the function will sum all cells that meet the set of criteria supplied. I can then say, if sumifs>0 then cell meets criteria supplied by the user










share|improve this question




















  • 1




    Just checking: Have you tried using the formula without the VBA to check that the formula itself is working as expected?
    – Mistella
    Nov 19 at 12:42










  • Hi Mistella - Thanks for replying. Yes I have, it works fine in the spreadsheet...
    – Jerbs
    Nov 19 at 12:44










  • Where are you setting i? Is it a single number, or part of a range (e.g. "3:H10")?
    – Chronocidal
    Nov 19 at 12:46










  • So what I've posted is nested within a for loop, for i = 2 to LastRow
    – Jerbs
    Nov 19 at 12:48












  • Also - your Excel and VBA formula are pointing to completely different columns? Is this deliberate, or have you mis-posted one of them?
    – Chronocidal
    Nov 19 at 12:52













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to code the following in VBA:



=SUMIFS(N2:N29,D2:D29,IF(COUNTIF(D2:D29,A36)=0,"*","="&A36),C2:C29,IF(COUNTIF(C2:C29,B36)=0,"*","="&B36),E2:E29,IF(COUNTIF(E2:E29,C36)=0,"*","="&C36),F2:F29,IF(COUNTIF(F2:F29,D36)=0,"*","="&D36))


The nested If and Countif are in there so that the Sumif ignores any condition that isn't required by the user (the user inputs A:B36), but still sums cells that meet all the remaining conditions.



I've written the following in vb (with criterias 1-3 determined in the same way):



If Application.WorksheetFunction.CountIf(Worksheets("Benchmark").Range("V" & i), Box4.Value) = 0 Then
criteria4 = "*"
Else
criteria4 = "=" & Box4.Value
End If

If criteria1 = "*" And criteria2 = "*" And criteria3 = "*" And criteria4 = "*" Then
dummy = 0
Else
dummy = Application.WorksheetFunction.SumIfs(Worksheets("Benchmark").Range("H" & i), Worksheets("Benchmark").Range("S" & i), criteria1, Worksheets("Benchmark") _
.Range("R" & i), criteria2, Worksheets("Benchmark").Range("C" & i), criteria3, Worksheets("Benchmark").Range("V" & i), criteria4)


but what is happening is that the sumifs is summing all cells that meet at least one of the conditions supplied, rather than all of them...



Does anyone know where I'm going wrong? Appreciate that this is a bit of a convoluted question, hope it makes sense...



Edit: To add context, the purpose of this code is to loop through a range, and find cells that meet criteria supplied by the user. However, if the user opts to supply certain criteria but not others, then those criteria not supplied are ignored. I've used a sumifs because my understanding is that the function will sum all cells that meet the set of criteria supplied. I can then say, if sumifs>0 then cell meets criteria supplied by the user










share|improve this question















I'm trying to code the following in VBA:



=SUMIFS(N2:N29,D2:D29,IF(COUNTIF(D2:D29,A36)=0,"*","="&A36),C2:C29,IF(COUNTIF(C2:C29,B36)=0,"*","="&B36),E2:E29,IF(COUNTIF(E2:E29,C36)=0,"*","="&C36),F2:F29,IF(COUNTIF(F2:F29,D36)=0,"*","="&D36))


The nested If and Countif are in there so that the Sumif ignores any condition that isn't required by the user (the user inputs A:B36), but still sums cells that meet all the remaining conditions.



I've written the following in vb (with criterias 1-3 determined in the same way):



If Application.WorksheetFunction.CountIf(Worksheets("Benchmark").Range("V" & i), Box4.Value) = 0 Then
criteria4 = "*"
Else
criteria4 = "=" & Box4.Value
End If

If criteria1 = "*" And criteria2 = "*" And criteria3 = "*" And criteria4 = "*" Then
dummy = 0
Else
dummy = Application.WorksheetFunction.SumIfs(Worksheets("Benchmark").Range("H" & i), Worksheets("Benchmark").Range("S" & i), criteria1, Worksheets("Benchmark") _
.Range("R" & i), criteria2, Worksheets("Benchmark").Range("C" & i), criteria3, Worksheets("Benchmark").Range("V" & i), criteria4)


but what is happening is that the sumifs is summing all cells that meet at least one of the conditions supplied, rather than all of them...



Does anyone know where I'm going wrong? Appreciate that this is a bit of a convoluted question, hope it makes sense...



Edit: To add context, the purpose of this code is to loop through a range, and find cells that meet criteria supplied by the user. However, if the user opts to supply certain criteria but not others, then those criteria not supplied are ignored. I've used a sumifs because my understanding is that the function will sum all cells that meet the set of criteria supplied. I can then say, if sumifs>0 then cell meets criteria supplied by the user







excel vba excel-vba sumifs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 12:53

























asked Nov 19 at 12:38









Jerbs

63




63








  • 1




    Just checking: Have you tried using the formula without the VBA to check that the formula itself is working as expected?
    – Mistella
    Nov 19 at 12:42










  • Hi Mistella - Thanks for replying. Yes I have, it works fine in the spreadsheet...
    – Jerbs
    Nov 19 at 12:44










  • Where are you setting i? Is it a single number, or part of a range (e.g. "3:H10")?
    – Chronocidal
    Nov 19 at 12:46










  • So what I've posted is nested within a for loop, for i = 2 to LastRow
    – Jerbs
    Nov 19 at 12:48












  • Also - your Excel and VBA formula are pointing to completely different columns? Is this deliberate, or have you mis-posted one of them?
    – Chronocidal
    Nov 19 at 12:52














  • 1




    Just checking: Have you tried using the formula without the VBA to check that the formula itself is working as expected?
    – Mistella
    Nov 19 at 12:42










  • Hi Mistella - Thanks for replying. Yes I have, it works fine in the spreadsheet...
    – Jerbs
    Nov 19 at 12:44










  • Where are you setting i? Is it a single number, or part of a range (e.g. "3:H10")?
    – Chronocidal
    Nov 19 at 12:46










  • So what I've posted is nested within a for loop, for i = 2 to LastRow
    – Jerbs
    Nov 19 at 12:48












  • Also - your Excel and VBA formula are pointing to completely different columns? Is this deliberate, or have you mis-posted one of them?
    – Chronocidal
    Nov 19 at 12:52








1




1




Just checking: Have you tried using the formula without the VBA to check that the formula itself is working as expected?
– Mistella
Nov 19 at 12:42




Just checking: Have you tried using the formula without the VBA to check that the formula itself is working as expected?
– Mistella
Nov 19 at 12:42












Hi Mistella - Thanks for replying. Yes I have, it works fine in the spreadsheet...
– Jerbs
Nov 19 at 12:44




Hi Mistella - Thanks for replying. Yes I have, it works fine in the spreadsheet...
– Jerbs
Nov 19 at 12:44












Where are you setting i? Is it a single number, or part of a range (e.g. "3:H10")?
– Chronocidal
Nov 19 at 12:46




Where are you setting i? Is it a single number, or part of a range (e.g. "3:H10")?
– Chronocidal
Nov 19 at 12:46












So what I've posted is nested within a for loop, for i = 2 to LastRow
– Jerbs
Nov 19 at 12:48






So what I've posted is nested within a for loop, for i = 2 to LastRow
– Jerbs
Nov 19 at 12:48














Also - your Excel and VBA formula are pointing to completely different columns? Is this deliberate, or have you mis-posted one of them?
– Chronocidal
Nov 19 at 12:52




Also - your Excel and VBA formula are pointing to completely different columns? Is this deliberate, or have you mis-posted one of them?
– Chronocidal
Nov 19 at 12:52












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Here is a version bodged together based on additional information garnered through the comments, that dispenses with the SumIfs entirely:



Dim dummy AS Long, IsValid AS Boolean

For i = 2 to LastRow
If Box1.Value & Box2.Value & Box2.Value & Box4.Value = "****" Then
dummy = 0
Else
IsValid = (Worksheets("Benchmark").Cells(i, "S").Value LIKE Box1.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "R").Value LIKE Box2.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "C").Value LIKE Box3.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "V").Value LIKE Box4.Value)

If IsValid Then
dummy = Worksheets("Benchmark").Cells(i, "H").Value
Else
dummy = 0
End If
End If

'Code to do stuff with dummy goes here

Next i


For each iteration of the For loop, we are using a Boolean variable to track if the row is valid, and LIKE statements to check each criteria. The 2nd comparison onwards use AND to make sure that you remember if the criteria has already failed.



A LIKE statement is similar to an = statement, but allows Wildcards - so, for example "SomeText" = "SomeOtherText" and "SomeText" LIKE "SomeOtherText" will both be False, whereas "Some*Text" = "SomeOtherText" will be False while "Some*Text" LIKE "SomeOtherText" will be True - since the "*" means "any text can go here".



(SumIfs uses a LIKE comparison instead of an = comparison, unless you specifically specify = at the start of the Condition.)






share|improve this answer





















  • Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
    – Jerbs
    Nov 19 at 13:37












  • So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
    – Jerbs
    Nov 19 at 13:44










  • @Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
    – Chronocidal
    Nov 19 at 15:44













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374841%2fcan-someone-help-me-understand-why-my-sumifs-isnt-working-in-vba%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Here is a version bodged together based on additional information garnered through the comments, that dispenses with the SumIfs entirely:



Dim dummy AS Long, IsValid AS Boolean

For i = 2 to LastRow
If Box1.Value & Box2.Value & Box2.Value & Box4.Value = "****" Then
dummy = 0
Else
IsValid = (Worksheets("Benchmark").Cells(i, "S").Value LIKE Box1.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "R").Value LIKE Box2.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "C").Value LIKE Box3.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "V").Value LIKE Box4.Value)

If IsValid Then
dummy = Worksheets("Benchmark").Cells(i, "H").Value
Else
dummy = 0
End If
End If

'Code to do stuff with dummy goes here

Next i


For each iteration of the For loop, we are using a Boolean variable to track if the row is valid, and LIKE statements to check each criteria. The 2nd comparison onwards use AND to make sure that you remember if the criteria has already failed.



A LIKE statement is similar to an = statement, but allows Wildcards - so, for example "SomeText" = "SomeOtherText" and "SomeText" LIKE "SomeOtherText" will both be False, whereas "Some*Text" = "SomeOtherText" will be False while "Some*Text" LIKE "SomeOtherText" will be True - since the "*" means "any text can go here".



(SumIfs uses a LIKE comparison instead of an = comparison, unless you specifically specify = at the start of the Condition.)






share|improve this answer





















  • Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
    – Jerbs
    Nov 19 at 13:37












  • So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
    – Jerbs
    Nov 19 at 13:44










  • @Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
    – Chronocidal
    Nov 19 at 15:44

















up vote
0
down vote













Here is a version bodged together based on additional information garnered through the comments, that dispenses with the SumIfs entirely:



Dim dummy AS Long, IsValid AS Boolean

For i = 2 to LastRow
If Box1.Value & Box2.Value & Box2.Value & Box4.Value = "****" Then
dummy = 0
Else
IsValid = (Worksheets("Benchmark").Cells(i, "S").Value LIKE Box1.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "R").Value LIKE Box2.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "C").Value LIKE Box3.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "V").Value LIKE Box4.Value)

If IsValid Then
dummy = Worksheets("Benchmark").Cells(i, "H").Value
Else
dummy = 0
End If
End If

'Code to do stuff with dummy goes here

Next i


For each iteration of the For loop, we are using a Boolean variable to track if the row is valid, and LIKE statements to check each criteria. The 2nd comparison onwards use AND to make sure that you remember if the criteria has already failed.



A LIKE statement is similar to an = statement, but allows Wildcards - so, for example "SomeText" = "SomeOtherText" and "SomeText" LIKE "SomeOtherText" will both be False, whereas "Some*Text" = "SomeOtherText" will be False while "Some*Text" LIKE "SomeOtherText" will be True - since the "*" means "any text can go here".



(SumIfs uses a LIKE comparison instead of an = comparison, unless you specifically specify = at the start of the Condition.)






share|improve this answer





















  • Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
    – Jerbs
    Nov 19 at 13:37












  • So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
    – Jerbs
    Nov 19 at 13:44










  • @Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
    – Chronocidal
    Nov 19 at 15:44















up vote
0
down vote










up vote
0
down vote









Here is a version bodged together based on additional information garnered through the comments, that dispenses with the SumIfs entirely:



Dim dummy AS Long, IsValid AS Boolean

For i = 2 to LastRow
If Box1.Value & Box2.Value & Box2.Value & Box4.Value = "****" Then
dummy = 0
Else
IsValid = (Worksheets("Benchmark").Cells(i, "S").Value LIKE Box1.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "R").Value LIKE Box2.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "C").Value LIKE Box3.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "V").Value LIKE Box4.Value)

If IsValid Then
dummy = Worksheets("Benchmark").Cells(i, "H").Value
Else
dummy = 0
End If
End If

'Code to do stuff with dummy goes here

Next i


For each iteration of the For loop, we are using a Boolean variable to track if the row is valid, and LIKE statements to check each criteria. The 2nd comparison onwards use AND to make sure that you remember if the criteria has already failed.



A LIKE statement is similar to an = statement, but allows Wildcards - so, for example "SomeText" = "SomeOtherText" and "SomeText" LIKE "SomeOtherText" will both be False, whereas "Some*Text" = "SomeOtherText" will be False while "Some*Text" LIKE "SomeOtherText" will be True - since the "*" means "any text can go here".



(SumIfs uses a LIKE comparison instead of an = comparison, unless you specifically specify = at the start of the Condition.)






share|improve this answer












Here is a version bodged together based on additional information garnered through the comments, that dispenses with the SumIfs entirely:



Dim dummy AS Long, IsValid AS Boolean

For i = 2 to LastRow
If Box1.Value & Box2.Value & Box2.Value & Box4.Value = "****" Then
dummy = 0
Else
IsValid = (Worksheets("Benchmark").Cells(i, "S").Value LIKE Box1.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "R").Value LIKE Box2.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "C").Value LIKE Box3.Value)
IsValid = IsValid And (Worksheets("Benchmark").Cells(i, "V").Value LIKE Box4.Value)

If IsValid Then
dummy = Worksheets("Benchmark").Cells(i, "H").Value
Else
dummy = 0
End If
End If

'Code to do stuff with dummy goes here

Next i


For each iteration of the For loop, we are using a Boolean variable to track if the row is valid, and LIKE statements to check each criteria. The 2nd comparison onwards use AND to make sure that you remember if the criteria has already failed.



A LIKE statement is similar to an = statement, but allows Wildcards - so, for example "SomeText" = "SomeOtherText" and "SomeText" LIKE "SomeOtherText" will both be False, whereas "Some*Text" = "SomeOtherText" will be False while "Some*Text" LIKE "SomeOtherText" will be True - since the "*" means "any text can go here".



(SumIfs uses a LIKE comparison instead of an = comparison, unless you specifically specify = at the start of the Condition.)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 13:23









Chronocidal

2,5301216




2,5301216












  • Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
    – Jerbs
    Nov 19 at 13:37












  • So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
    – Jerbs
    Nov 19 at 13:44










  • @Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
    – Chronocidal
    Nov 19 at 15:44




















  • Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
    – Jerbs
    Nov 19 at 13:37












  • So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
    – Jerbs
    Nov 19 at 13:44










  • @Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
    – Chronocidal
    Nov 19 at 15:44


















Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
– Jerbs
Nov 19 at 13:37






Thanks for taking the time to write this. Just so I understand correctly, will this code only check for criteria that are supplied by the user? And ignore any that aren't supplied?
– Jerbs
Nov 19 at 13:37














So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
– Jerbs
Nov 19 at 13:44




So I suppose there are two things; the code has to ignore any conditions not supplied by the user, and only evaluate as True if all conditions that are supplied are satisfied
– Jerbs
Nov 19 at 13:44












@Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
– Chronocidal
Nov 19 at 15:44






@Jerbs If the Box#.Value is "*" when the user has not specified a criteria, then that check will automatically evaluate as True (since Variable LIKE "*" means "Variable is anything, including an empty string") unless your variable contains an error code. (In which case, you will get a "Type Mismatch" error)
– Chronocidal
Nov 19 at 15:44




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374841%2fcan-someone-help-me-understand-why-my-sumifs-isnt-working-in-vba%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen