Return multiple values in a list based on other criteria

BigTenBoy15

New Member
Joined
Feb 24, 2016
Messages
9
I'm shooting for the moon a bit here, but thought I'd ask if this is possible anyway. In the below table, I want to make a list of values appear in column E based on the number in column B (as it's shown now with hard-coded values). For example, if there's a 2 next to QB, then QB would show up twice on that list and push everything down. Is there any way to do this in Excel? Thanks in advance for the help!

ABCD
Roster SettingsNumber of StartersTeam List
QB
1​
QB
RB
2​
RB
WR
3​
RB
TE
1​
WR
Flex
1​
WR
DST
1​
WR
Bench
6​
TE
Total Players
15​
Flex
DST
Bench
Bench
Bench
Bench
Bench
Bench
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Run this macro

VBA Code:
Sub Return_multiple_values()
  Dim i As Long, j As Long, k As Long
  k = 2
  For i = 2 To Range("B" & Rows.Count).End(xlUp).Row - 1
    For j = 1 To Range("B" & i)
      Range("E" & k).Value = Range("A" & i).Value
      k = k + 1
    Next
  Next
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Return_multiple_values) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,223,922
Messages
6,175,406
Members
452,640
Latest member
steveridge

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