Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SumIf Calculation in Code Problem

I think this is what you need

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<" & XXX, ActiveWorkbook.Sheets("Sheet1").Columns(1))

The < is a string and XXX is a variable which is a number. The & combines
a strinhg and a number and makes the results a string.


"Arturo" wrote:

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

The above code works but, the problem Im encountering has to do with
factoring in a number associated with a variable, X, into the denominator of
this formula. X resides elsewhere, I can pull it with no problem. Whatever
SumIf of column 1 is, I want to add X to that summation but am not finding
the correct syntax to do so. Any direction would be appreciated.

Arturo

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default SumIf Calculation in Code Problem

Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

This sums numbers in column 1 when the string XXX does not reside in column
2.
Lets call the variable I need to add Var1 instead of X.

A1 = 10, A2 = XXX
B1 = 10, B2 = blank
Var1 = 10

The result in the divisor of the full formula should be 20.



"Joel" wrote:

I think this is what you need

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<" & XXX, ActiveWorkbook.Sheets("Sheet1").Columns(1))

The < is a string and XXX is a variable which is a number. The & combines
a strinhg and a number and makes the results a string.


"Arturo" wrote:

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

The above code works but, the problem Im encountering has to do with
factoring in a number associated with a variable, X, into the denominator of
this formula. X resides elsewhere, I can pull it with no problem. Whatever
SumIf of column 1 is, I want to add X to that summation but am not finding
the correct syntax to do so. Any direction would be appreciated.

Arturo

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SumIf Calculation in Code Problem

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<" & Var1, ActiveWorkbook.Sheets("Sheet1").Columns(1))

the columns 1 & 2 can also be replaced with variables. Something like
"sheet1" can also be replaces with "sheet" & Mysheet
"Arturo" wrote:

Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

This sums numbers in column 1 when the string XXX does not reside in column
2.
Lets call the variable I need to add Var1 instead of X.

A1 = 10, A2 = XXX
B1 = 10, B2 = blank
Var1 = 10

The result in the divisor of the full formula should be 20.



"Joel" wrote:

I think this is what you need

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<" & XXX, ActiveWorkbook.Sheets("Sheet1").Columns(1))

The < is a string and XXX is a variable which is a number. The & combines
a strinhg and a number and makes the results a string.


"Arturo" wrote:

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

The above code works but, the problem Im encountering has to do with
factoring in a number associated with a variable, X, into the denominator of
this formula. X resides elsewhere, I can pull it with no problem. Whatever
SumIf of column 1 is, I want to add X to that summation but am not finding
the correct syntax to do so. Any direction would be appreciated.

Arturo

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default SumIf Calculation in Code Problem

"<XXX" has to be inplace as an exclusion flag.
"<" & Var1 still doesn't factor in the number associated with Var1 nor
does "<XXX" & Var1. Still cannot find a way to add Var1 into the divisor of:

Numerator/ _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

"Joel" wrote:

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<" & Var1, ActiveWorkbook.Sheets("Sheet1").Columns(1))

the columns 1 & 2 can also be replaced with variables. Something like
"sheet1" can also be replaces with "sheet" & Mysheet
"Arturo" wrote:

Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

This sums numbers in column 1 when the string XXX does not reside in column
2.
Lets call the variable I need to add Var1 instead of X.

A1 = 10, A2 = XXX
B1 = 10, B2 = blank
Var1 = 10

The result in the divisor of the full formula should be 20.



"Joel" wrote:

I think this is what you need

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<" & XXX, ActiveWorkbook.Sheets("Sheet1").Columns(1))

The < is a string and XXX is a variable which is a number. The & combines
a strinhg and a number and makes the results a string.


"Arturo" wrote:

ActiveWorkbook.Sheets("Sheet1").Cells(i, 3).Value = _
ActiveWorkbook.Sheets("Sheet1").Cells(i, 1) / _
Application.SumIf(ActiveWorkbook.Sheets("Sheet1"). Columns(2), _
"<XXX", ActiveWorkbook.Sheets("Sheet1").Columns(1))

The above code works but, the problem Im encountering has to do with
factoring in a number associated with a variable, X, into the denominator of
this formula. X resides elsewhere, I can pull it with no problem. Whatever
SumIf of column 1 is, I want to add X to that summation but am not finding
the correct syntax to do so. Any direction would be appreciated.

Arturo

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limitations on Sumif Calculation TaraD[_2_] Excel Worksheet Functions 3 January 26th 10 10:50 PM
Help to create calculation with code Les Stout[_2_] Excel Programming 0 April 7th 08 12:19 PM
Calculation on SUMIF Results Andy B Excel Worksheet Functions 3 October 9th 05 04:47 AM
SUMIF function in "Price quote with tax calculation" templae Peter Excel Worksheet Functions 6 October 3rd 05 07:18 PM
Code Calculation Problem Shawn Excel Programming 16 July 20th 05 06:12 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"