Solved

Use VLookup or is there a macro that would be better?

Posted on 2011-03-15
10
340 Views
Last Modified: 2012-05-11
The object of the exercise is to get the Trans Total from trans.xls into the Period Total column of master.xls by cross-referencing the Badge Number.  

Trans is always a subset of Master, so the number of rows in trans.xls will never exceed the number of rows in master.xls.  

Any badge number found in trans.xls should exist in master.xls.  Whatever value is in Period Total will be overwritten to the Trans Total if badge numbers match, or be re-set to zero.  

The result should then be saved as summary_{date}.xls.

What can be tricky about this whole process is the following:

Every a week, the Accountant runs a report that summarizes all the transactions by badge and totals the transactions for the week.  

The Accountant then exports the report to a CSV and sends it to a Junior Admin Person.  

The Junior Admin Person currently manually cross-references the employee name and number and inserts it into a spreadsheet (Trans File) and sends it back to the Accountant who then sends it to corporate.  

The Accountant *could* do it, but wants the Junior Admin Person to do it instead.
 master.xls
trans.xls
0
Comment
Question by:Alex972
  • 5
  • 4
10 Comments
 
LVL 20

Expert Comment

by:pari123
Comment Utility
i think it would be easier to code a macro rather than using vlookup.
0
 

Author Comment

by:Alex972
Comment Utility
Can you write the macro?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
I would like a few clarifications before I attempt this.

- Will the trans sheet contain the badge numbers before running the macro

- Will this list in trans fixed or varying

- Could it be that the trans list is created based on non-zero values in master list

- At the moment the master list does not contain any value in the period total. There should be values present there to be posted to the trans.
0
 

Author Comment

by:Alex972
Comment Utility


- Will the trans sheet contain the badge numbers before running the macro
yes

- Will this list in trans fixed or varying
Will vary

- Could it be that the trans list is created based on non-zero values in master list
No

- At the moment the master list does not contain any value in the period total. There should be values present there to be posted to the trans.  

***Thinks it goes the other way: from Trans to Master, but will double-check with customer.***

"The object of the exercise is to get the Trans Total from trans.xls into the Period Total column of master.xls by cross-referencing the Badge Number.  

Any badge number found in trans.xls should exist in master.xls.  Whatever value is in Period Total will be overwritten to the Trans Total if badge numbers match, or be re-set to zero.

The result should then be saved as summary_{date}.xls. "



-------------------------------------------------------------------------------------------------------------------------
The object of the exercise is to get the Trans Total from trans.xls into the Period Total column of master.xls by cross-referencing the Badge Number.  

Trans is always a subset of Master, so the number of rows in trans.xls will never exceed the number of rows in master.xls.  

Any badge number found in trans.xls should exist in master.xls.  Whatever value is in Period Total will be overwritten to the Trans Total if badge numbers match, or be re-set to zero.  

The result should then be saved as summary_{date}.xls.

What can be tricky about this whole process is the following:

Every a week, the Accountant runs a report that summarizes all the transactions by badge and totals the transactions for the week.  

The Accountant then exports the report to a CSV and sends it to a Junior Admin Person.  

The Junior Admin Person currently manually cross-references the employee name and number and inserts it into a spreadsheet (Trans File) and sends it back to the Accountant who then sends it to corporate.  

The Accountant *could* do it, but wants the Junior Admin Person to do it instead.
0
 

Author Comment

by:Alex972
Comment Utility
Information below --------- was put there while I was editing. Meant to delete before sending.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Alex972
Comment Utility
Checked with customer. The answers I gave above are correct.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
This is an exerpt from the question

Any badge number found in trans.xls should exist in master.xls.  Whatever value is in Period Total will be overwritten to the Trans Total if badge numbers match, or be re-set to zero.  

and this one from your response to my queries

***Thinks it goes the other way: from Trans to Master

You need to clarify this. If the latter is the case then my queries are no longer relevant.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
So the statement in the question is wrong?
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
Comment Utility
enter this formula in D2 and then copy it down

=IF(ISNA(VLOOKUP(C2,[trans.xls]nptest!$A:$B,2,0)),0,VLOOKUP(C2,[trans.xls]nptest!$A:$B,2,0))
 
0
 

Author Closing Comment

by:Alex972
Comment Utility
Customer very pleased, but had one suggestion that instead of choosing all rows, just use a1 to B500. Covers any possible situation, but is much faster than whole column.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now