#1
|
|||
|
|||
code to find account and sum up values
I am trying to design a code that operates on two sheets in Excel. On the first sheet is an account number and on the second sheet is the same account number with itemized values, for example:
sheet 1: account # --------------- Total 115 116 117 118 sheet 2: account # ------- amount 115 -------------- 10 115 -------------- 20 115 -------------- 30 116 Now I need to write a code that searches sheet 2 for all itemized accounts, lets say account 115 and sums up all those values, here it would be 60 and then places that total under account 115 on sheet 1, then it needs to switch to account 116 and do the same process. what I have developed as psuedocode is: sub organize() worksheets("sheet 1 Acct #").Range("G1")=n <G1 is sheet 1 account #> n+1=m <this is to always search the next account number> <I know I will need another equation to search for the next account> find m worksheets("sheet 2 Acct #").Range("B1")=p <B1 is sheet 2 account #> p+1=q if worksheets("sheet 2 Acct #").Range(q) = worksheets("sheet 1 Acct #").Range("m") Next Cell else sum() <if only 1 cell contains a value it would be entered on sheet 1, not sure how to match corresponding cell> Do until worksheets("sheet 2 Acct #").Range("q") <> worksheets("sheet 1 Acct #").Range("m") then sum() <not sure how to match corresponding cell and create a range> end sub Any help would be appreciated in fleshing out the psuedocode or ideas. thanks |
#2
|
||||
|
||||
At first glance it looks like a Pivot Table would do the job.
Perhaps use code to create a PT in sheet1? EDIT http://contextures.com/CreatePivotTable.html
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#3
|
|||
|
|||
Use SUMIF formula on sheet1!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find and replace multiple values, according to table value - excel formula | EtanM | Excel Programming | 3 | 04-11-2016 01:43 AM |
Code to Sum Column of Content Control Values In Specific Tables? | warbird | Word VBA | 2 | 07-13-2015 05:44 AM |
Require assistance in writing code to login to webmail account. | saurabhlotankar | Excel Programming | 4 | 05-21-2015 10:47 AM |
find 2 values i a table to find the right prise | Vibov | Excel | 1 | 01-11-2015 07:25 AM |
How to find RBG values for Office 2003 palette? | alicorn2 | Outlook | 2 | 07-10-2009 02:24 PM |