Excel Macro Help - Trying to create either a function or macro

I am at my wits end trying to create either a function or a macro to import data from one worksheet to another. I have total sales for a SKU on one worksheet and on another worksheet, I have the same SKU's but in a different order and cannot readjust the order. In the second worksheet I want it to pull total sales for that SKU from the first worksheet and enter it into the cell on the second worksheet that corresponds to that SKU.

For example:

Worksheet 1:

SKU YTD Sales xxxxxx1 4 xxxxxx2 6 xxxxxx3 8 xxxxxx4 9

Worksheet 2: SKU YTD Sales xxxxxx1 this is where I want the data put into from Worksheet 1 xxxxxx4 xxxxxx2 xxxxxx3

I am trying to eliminate would could end up to be days upon days of data entry. Any ideas?

THANKS!

7 Comments
 

use a sumif on worksheet 2: Assuming that SKU and YTD Sales are A1 and B1: in ws2 in B2, put =SUMIF('Sheet1'!$A$2:$B$5000,$A2,'Sheet1'!$B$2:$B$5000)

have fun edit: above poster is right as well, the only reason i used sumif is to account for the possibility of the sku being listed multiple times on worksheet 1

 

thanks! I had tried VLOOKUP numerous times without success but your guys' reassuring comments kept me at it and I finally got it to work.

 
Best Response

The best way to do this via excel macros is to create a loop with this kind of structure:

If Workbooks(1).Sheets(1).Cells(rowNum, 1) = "SKU1" Then Workbooks(2).Sheets(1).Cells(1, colNum) = Workbooks(1).Sheets(1).Cells(rowNum, 5) End If

rowNum is a variable that changes every time the loop is finished via rowNum = rowNum + 1 at the bottom of the loop.

The way you want to read this is "If the entry in the first column and rowNum row of my first worksheet equals SKU1, then my second worksheet pulls the value 5 columns over from that entry and plugs it into the first column of the first row."

The idea here is that the loop checks every single row for "SKU1" and when it finds SKU1 it takes the information you want. So what you need to do is make a loop that has a statement like the one above for each individual SKU# so that the loop checks every line for every SKU#. colNum may or may not be something you need depending on whether or not you plan on having multiple dates going.

I know this can be confusing but send me a PM if you have anymore questions. This way is better than VLOOKUP once you put in the initial grunt work of understanding what's going on.

 

Perferendis distinctio porro non. Perspiciatis est neque voluptas veritatis fugit non voluptas. Nihil voluptatem qui rerum et ut.

Tempore vitae id veritatis. Non doloremque non et aliquid inventore quisquam omnis sint. Et eveniet maxime quas maiores alias.

Expedita sint expedita id omnis in. Voluptas mollitia exercitationem est consequatur autem eum itaque tempora. Labore beatae quas rerum fuga tempora et sunt ullam.

Career Advancement Opportunities

June 2026 Investment Banking

  • Evercore 01 99.4%
  • Moelis & Company 01 98.8%
  • JPMorgan 01 98.2%
  • Guggenheim Partners 01 97.7%
  • Morgan Stanley 07 97.1%

Overall Employee Satisfaction

June 2026 Investment Banking

  • Moelis & Company No 99.4%
  • Morgan Stanley 01 98.8%
  • Evercore 01 98.2%
  • BMO Capital Markets 12 97.6%
  • Banco Santander 01 97.1%

Professional Growth Opportunities

June 2026 Investment Banking

  • Moelis & Company No 99.4%
  • Evercore No 98.8%
  • Morgan Stanley 05 98.2%
  • JPMorgan No 97.7%
  • BMO Capital Markets 12 97.1%

Total Avg Compensation

June 2026 Investment Banking

  • Vice President (14) $434
  • Associates (43) $259
  • 3rd+ Year Analyst (8) $210
  • 2nd Year Analyst (22) $179
  • Intern/Summer Associate (13) $156
  • 1st Year Analyst (75) $151
  • Intern/Summer Analyst (65) $101
notes
16 IB Interviews Notes

“... there’s no excuse to not take advantage of the resources out there available to you. Best value for your $ are the...”

Leaderboard

1
redever's picture
redever
99.2
2
BankonBanking's picture
BankonBanking
99.0
3
kanon's picture
kanon
99.0
4
Secyh62's picture
Secyh62
99.0
5
DrApeman's picture
DrApeman
98.9
6
Betsy Massar's picture
Betsy Massar
98.9
7
CompBanker's picture
CompBanker
98.9
8
dosk17's picture
dosk17
98.9
9
GameTheory's picture
GameTheory
98.9
10
Jamoldo's picture
Jamoldo
98.8
success
From 10 rejections to 1 dream investment banking internship

“... I believe it was the single biggest reason why I ended up with an offer...”