Excel VBA : Match the data from another workbook and return another column value

jocquedemus

New Member
Joined
Aug 23, 2022
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Screenshot 2022-08-24 091705.png

So, i have a 'Summary' workbook that consists of zone, state, city, and total income. Inside one zone, there are a states. And inside the states, there are a cities. What i'm trying to do is to find the total income of each city in column D and summarize the total income of each state. To get the 'total income' value, i match it from the 'raw data' workbook. Here's the example :
Screenshot 2022-08-24 091731.png

To get the 'total income' value, i need to match the 'City' column in 'raw data' workbook (Column B) with the 'City' column in 'Summary' workbook (Column C). If the criteria is matched, it will return the value of 'Income' column in 'raw data' workbook (Column C) and summarize the income of each city. This is just an example, the real data has thousands of row so i need a program that run fast.
Any help would be greatly appreciated. :)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
You can do this using a simple VLOOKUP formula by matching the City and returning the column you want using {#,#,#,#}, the hashtags representing the number of the columns you want to return. 1 = column A, 2 = Column B etc... YouTube Video
 
Upvote 0
You can do this using a simple VLOOKUP formula
I don't think so since, for example, city A1 appears several times in the raw data and VLOOKUP would only return the first value.

@jocquedemus
Welcome to the MrExcel board!

You will generally get faster and better help if you post your sample data with XL2BB as we can then easily copy it to test with. :)

Also, it looks like the figures in the INCOME column of raw data are numbers stored as text. It would be better if you were able to have those values as actual numbers as you could then use a SUMIF or SUMIFS function.

However, as it stands, see if this helps.

jocquedemus.xlsm
BC
1CityINCOME
2A13
3A15
4A32
5A24
6B18
7B26
8B25
9A14
10C14
11C28
12C19
raw data


Adjust the ranges in the formula to suit your data

jocquedemus.xlsm
CD
1Citytotal income
2A112
3A24
4A32
5B18
6B211
7C113
8C28
9D10
Summary
Cell Formulas
RangeFormula
D2:D9D2=SUMPRODUCT(--('raw data'!B$2:B$100=C2),--'raw data'!C$2:C$100)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top