Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2017, 08:41 AM
Brian13 Brian13 is offline code to find account and sum up values Windows 10 code to find account and sum up values Office 2010 64bit
Novice
code to find account and sum up values
 
Join Date: May 2017
Posts: 2
Brian13 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 05-31-2017, 09:17 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline code to find account and sum up values Windows 7 64bit code to find account and sum up values Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

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
Reply With Quote
  #3  
Old 05-31-2017, 09:26 AM
ArviLaanemets ArviLaanemets is offline code to find account and sum up values Windows 8 code to find account and sum up values Office 2016
Expert
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default

Use SUMIF formula on sheet1!
Reply With Quote
Reply



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 find account and sum up values 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
code to find account and sum up values How to find RBG values for Office 2003 palette? alicorn2 Outlook 2 07-10-2009 02:24 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft