DarrenJackson
asked on
Excel vba question
Hi Guys,
I am trying to get this working in excel vb
If Application.WorksheetFunct ion.SumIf( Sheet2.Ran ge("$A$2:$ A$5000"), Sheet2.Range("$A$2:$A$5000 "), Sheet2.Range("$I$2:$I$5000 ")) = Round(Sheet2.Cells(r, "F") * 52 / 12, 2) Then
Sheet2.Cells(r, "I").Interior.ColorIndex = xlNone
Else
Sheet2.Cells(r, "I").Interior.ColorIndex = 3
End If
it doesn't error but doesn't do as I'm expecting
it is part of a bigger piece of code and loops through the rows and I want it to run the SUMIF statement and if it matches as per the above script then don't colour the cell but if it doesn't then change cell to RED
any ideas where I am going wrong
Regards
I am trying to get this working in excel vb
If Application.WorksheetFunct
Sheet2.Cells(r, "I").Interior.ColorIndex = xlNone
Else
Sheet2.Cells(r, "I").Interior.ColorIndex = 3
End If
it doesn't error but doesn't do as I'm expecting
it is part of a bigger piece of code and loops through the rows and I want it to run the SUMIF statement and if it matches as per the above script then don't colour the cell but if it doesn't then change cell to RED
any ideas where I am going wrong
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Guys thank you all for commenting I have checked over the solutions and RGonzo1971 has the solution. It appears I was
incorrectly formulating the sum if
from
If Application.WorksheetFunct ion.SumIf( Sheet2.Ran ge("$A$2:$ A$5000"), Sheet2.Range("$A$2:$A$5000 "), Sheet2.Range("$I$2:$I$5000 ")) = Round(Sheet2.Cells(r, "F") * 52 / 12, 2) Then
to this
If Application.WorksheetFunct ion.SumIf( Sheet2.Ran ge("$A$2:$ A$5000"), Sheet2.Cells(r, "A"), Sheet2.Range("$I$2:$I$5000 ")) = Round(Sheet2.Cells(r, "F") * 52 / 12, 2) Then
This now works as I need
Thank you all for helping
incorrectly formulating the sum if
from
If Application.WorksheetFunct
to this
If Application.WorksheetFunct
This now works as I need
Thank you all for helping
ASKER
Thanks for helping
The range and the criteria of the SUMIF is the same is that right?
Regards