LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA SUM Function

Dave and I have shown you the SUMPRODUCT and you keep on going back to the
SUMIF which won't work.

"joecrabtree" wrote:

On Mar 26, 11:19 am, joel wrote:
I'm not sure exactly what you have in mind. There are a few different
methods people ask for in similar situations.

1) If you want to create the table in the output and don't havve all the
codes. then what you need to do is to get unique codes. On a worksheet you
can go to the menu - Data - Advance filter. Select the original data table
to the code colun. Then select copy to a new location. Specify the new
location, and also select Unique. You can record a macro will performing
this operation.

2) Once you have the unique values in the outp[ut table then you can add the
Y or N in the column B and the formula in column S.

----------------------------------------------------------------------------
Now if you already have the table and want to condense the table yo would
want to replace the formula with values. Then combine rows that have the
same code. You would need to sort the table to make sure items with the same
code are adjacent. Then it is a simple macro to combine the rows and add the
values.

I will help with anything you want. But I want to make sure I'm writing
the macro you want.

"joecrabtree" wrote:
On Mar 26, 8:17 am, joecrabtree wrote:
On Mar 25, 2:29 pm, joel wrote:


You can also put the sumproduct formula in the worksheet


from
MyFormula = "Sumproduct(" & _
"--(" & CodeRange.Address(external:=true) & "=""" _
& .Range("K" & r).Value & """)," & _
"--(" & CriteriaRange.Address(external:=true) & "=""Y"")," & _
SumRange.Address(external:=true) & ")"


to (added equal sign in front of forumal)
MyFormula = "=Sumproduct(" & _
"--(" & CodeRange.Address(external:=true) & "=""" _
& .Range("K" & r).Value & """)," & _
"--(" & CriteriaRange.Address(external:=true) & "=""Y"")," & _
SumRange.Address(external:=true) & ")"
Range("A1").formula = Myformula


"Dave Peterson" wrote:
Got it working means that
Total = Application.Evaluate(MyFormula)
actually evaluated to the correct number?


If yes, then maybe something like after this line:


Total = Application.Evaluate(MyFormula)
..Range("X" & r).Value = total


joecrabtree wrote:


<<snipped


Thanks for all your help. Ive now got this working, and understand how
it works. However I havent been able to get an output, i.e. displayed
sumproduct value. For example how would I be able to get this to
display the outputs an output worksheet?


Thanks again,


Joe Crabtree


--


Dave Peterson


All,


Thankyou both for your input. I now have another question based on
this code.Using this code I have a workbook with a worksheet in it
called 'data'. The format is shown below:


Column Letter B K S
1 YES/NO CODE VALUE
2 Y ABC 10
3 Y ABC 2
4 N ABB 44
5 N ABC 23


Apologies- that was posted in error!


Thankyou both for your input. I now have another question based on
this code.Using this code I have a workbook with a worksheet in it
called 'data'. The format is shown below:


B K S
1 YES/NO CODE VALUE
2 Y ABC 10
3 Y ABC 2
4 N ABB 44
5 N ABC 23


I also have another sheet called 'output' . What I would like to do is
sum all of the code values based on the Y/N criteria. For example in
this case. The output would be:


B K S
1 YES/NO CODE VALUE
2 Y ABC 12


If the data changed to:


B K S
1 YES/NO CODE VALUE
2 Y ABC 10
3 Y ABC 2
4 Y ABB 44
5 N ABC 23


Then the output would be:


B K S
1 YES/NO CODE VALUE
2 Y ABC 12
3 Y ABB 44


and so on. The data is in columns B (Y/N), K (CODE), and S(Value).


Do you have any idea how I can make this work?


Thanks in advance for all your help,


Regards


Joseph Crabtree


My idea was to do the whole thing using VBA, i.e completed automated.
The ideal solution would be the first one that you suggested:

1) If you want to create the table in the output and don't havve all
the
codes. then what you need to do is to get unique codes. On a
worksheet you
can go to the menu - Data - Advance filter. Select the original data
table
to the code colun. Then select copy to a new location. Specify the
new
location, and also select Unique. You can record a macro will
performing
this operation.

2) Once you have the unique values in the outp[ut table then you can
add the
Y or N in the column B and the formula in column S.

Any help you could give would be much appreciate.

Regards

Joe Crabtree



 
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
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
User Function Question: Collect Condition in Dialog Box - But How toInsert into Function Equation? SteveM Excel Programming 1 January 3rd 08 03:45 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM


All times are GMT +1. The time now is 06:53 AM.

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"