Fill values based on a starting value in one cell with the number in another cell (macro?)

muhleebbin

Active Member
Joined
Sep 30, 2017
Messages
252
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hey all,

I deal with a lot of ticket rolls in my industry and was wondering if there's a way to simplify counting the number of tickets used for a venue.

On sheet 1 i'd like to have column a be a starting value of ticket #, column b the number of tickets in the roll (i.e. 1000 or 20000) and column c be the venue. On sheet 2, i'd like column a to be filled with row 1 the starting value and all rows filled with the series of numbers up until the value of column b in sheet 1. Column b (in sheet 2) to be filled with 1 - (value of column b sheet 1), and column c filled with the venue.

Sheet 3 eventually is my lookup tool for starting number vs ending number using vlookups to find the number of tickets used for a particular venue on a particular day.

example below

sheet 1:
1000012000xyz
700011000abc
1250012000123

<tbody>
</tbody>

sheet 2:
Row NumberTicket NumberTicket Number 2Venue
11000011xyz
20001020002000xyz
2001700011abc
3000710001000abc
300112500011123
500012700002000123

<tbody>
</tbody>


Any other suggestions on how to tackle this would be much appreciated as well. Thanks in advance
 
Yes:


Excel 2010
ABCD
1
2A1000012000xyz
3B700011000abc
4C1250012000123
5A1260011000jkl
6
7A126002jkl
Sheet5
Cell Formulas
RangeFormula
C7{=INDEX($D$1:$D$5,SUM(IF($B$2:$B$5<=$B7,IF(($B$2:$B$5+$C$2:$C$5)>=$B7,IF($A$2:$A$5=A7,ROW($B$2:$B$5))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
This works perfectly! Thank you so much for your help on this
 
Upvote 0
Spoke too soon :(

This array formula, for some reason, hates the first number in a roll. If line 4 column a is changed to "A", inputting 126001 in b7 will result in a #REF ! error. It looks like the sum portion of the formula is finding both rows 4 & 5 because they're both true in this instance.
 
Upvote 0
You mean this?


Excel 2010
ABCD
1
2A1000012000xyz
3B700011000abc
4A1250012000123
5A1260011000jkl
6
7A126002#REF!
Sheet12
Cell Formulas
RangeFormula
C7{=INDEX($D$1:$D$5,SUM(IF($B$2:$B$5<=$B7,IF(($B$2:$B$5+$C$2:$C$5)>=$B7,IF($A$2:$A$5=A7,ROW($B$2:$B$5))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


Of course, that was the reason for having two different letters. Otherwise how can you distinguish the two?
 
Last edited:
Upvote 0
In some instances we'll get 30,000 tickets where they're sequential. 125001 - 165000 so we'll have rolls of 2000 with 125001, 127001, 129001 and so on. They're all the same ticket type but 127001, 129001 etc will all have issues within this formula. Even if you change row 4 to A, 125001, 1000 jkl it'll still bring up a #REF ! error. 126002 will now work but 126001 will bring up a #REF ! error

Sorry for the inconvenience and as always grateful for your help.
 
Last edited:
Upvote 0
Because there are duplicate (non-unique) rows. The formula in post #9 returns a list of venues, are you sure that doesn't work for you?
 
Upvote 0
Post 9's formula worked, however we do have overlapping numbers of ticket types which is why I added column A in post 10. Below is actual data i'm working off of. This is just a sample size but as you can see the Beer Tasting tickets started running into the Admission tickets. This is where I ran into issues and it's only the starting numbers as that brings in values in the first two 'if' formulas

Ticket TypeStarting Ticket NumberNumber of TicketsEnding Ticket NumberVenueEvent
Beer Ticket64001200066000Main TentOktoberfest
Beer Tasting5200012000522000Beer TastingTaste of Tacoma
Beer Tasting5220012000524000Beer TastingTaste of Tacoma
Beer Tasting5240012000526000Beer TastingTaste of Tacoma
Admission4880012000490000Blue GateOktoberfest
Admission4900012000492000Blue GateOktoberfest
Admission4920012000494000Blue GateOktoberfest
Admission4940012000496000Blue GateOktoberfest
Admission4960012000498000Blue GateOktoberfest
Admission4980012000500000Blue GateOktoberfest
Admission5000012000502000Blue GateOktoberfest
Admission5020012000504000Blue GateOktoberfest
Admission5040012000506000Blue GateOktoberfest
Admission5060012000508000Blue GateOktoberfest
Admission5080012000510000Blue GateOktoberfest
Admission5100012000512000Blue GateOktoberfest
Admission5120012000514000Blue GateOktoberfest
Admission5140012000516000Blue GateOktoberfest
Admission5160012000518000Blue GateOktoberfest
Admission5180012000520000Blue GateOktoberfest
Admission5200012000522000Blue GateOktoberfest
Admission5220012000524000Blue GateOktoberfest

<colgroup><col span="6"></colgroup><tbody>
</tbody>
 
Upvote 0
Actually I kind of solved the problem, just needed to change the number of tickets to 1999 and it solves the overlap in the starting number
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,030
Members
449,205
Latest member
Eggy66

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