ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sumif in vba (https://www.excelbanter.com/excel-programming/429191-sumif-vba.html)

RobcPettit[_2_]

sumif in vba
 
Hi Im trying to use =(SUMIF(teams,Home,power)) with vba. teams,home
and power are named ranges. The calc works perfect in excel. Ive
tried
Dim xt As Double
xt = Application.WorksheetFunction.SumIf(Range("teams") , Range
("Home"), Range("Power"))
MsgBox xt.

The reason I want to do this is, in excel the calc is dependent on
other data, and when calculated I dont want the value to change, but
because its calc from other data which changes daily the value changes
to, so I thought Id calc using vba and write the value to appropiate
range then when values change this result wont. Basically its the
previous days result.
Thanks Regards Robert

royUK[_130_]

sumif in vba
 

Is Range("home") the criteria for the SUMIF?


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=102011


[email protected]

sumif in vba
 
On 31 May, 09:59, royUK wrote:
Is Range("home") the criteria for the SUMIF?

--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile:http://www.thecodecage.com/forumz/member.php?userid=15
View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=102011


thanks for replying. Yes it is.
Robert

royUK[_131_]

sumif in vba
 

The code works for me on a dummy workbook.

Is Range("Home") a single cell?


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=102011


Robert McCurdy

sumif in vba
 
Hi Robert,

The syntax you have used should work as can the one below:
xt = [SUMIF(teams,Home,power) ]

Check your named ranges to see if the ranges 'teams' and 'power' are the
same dimensions, and 'Home' holds a valid criteria.


Regards
Robert McCurdy
"RobcPettit" wrote in message
...
Hi Im trying to use =(SUMIF(teams,Home,power)) with vba. teams,home
and power are named ranges. The calc works perfect in excel. Ive
tried
Dim xt As Double
xt = Application.WorksheetFunction.SumIf(Range("teams") , Range
("Home"), Range("Power"))
MsgBox xt.

The reason I want to do this is, in excel the calc is dependent on
other data, and when calculated I dont want the value to change, but
because its calc from other data which changes daily the value changes
to, so I thought Id calc using vba and write the value to appropiate
range then when values change this result wont. Basically its the
previous days result.
Thanks Regards Robert





All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com