Originally Posted by
benishiryo
you can shorten your AE3001 formula to just:
=IFERROR(VLOOKUP(A15,'Data(1)'!A:C,3,0),"")
VLOOKUP is basically looking at A15 inside column A of Data sheet. once it found the first instance, i label 3 to extract the 3rd column from Column A, so that's column C. note that my 2nd argument in the VLOOKUP formula must include Column A where lookup_value can be found and all the way to column C where the value i want is. the last argument of VLOOKUP is a 0 for finding exact match. some people use FALSE. works the same. IFERROR helps you return a blank when the lookup_value cannot be found
you can adjust Column AB accordingly. i saw that it is taking different values and i don't wish to meddle with it.
for your dynamic range, i saw that your formula ends in row 3050 nicely. i'm wondering if it's really the case of you are trying to simplify things. a formula for dynamic range is extremely sensitive, so these tiny little details matter a lot. if it ends nicely 1 row after where you should print, then press CTRL + F3 to use the Name Manager. you will see a Print_Area name. click on that and click on the Refers to. put in:
=$AD$3001:INDEX($AH:$AH,3000+COUNTA($AH$3001:$AH$10000)-1)
i indicate that my row starts from AD3001. i then make the end part a variable. by using the INDEX formula, i can indicate where i want it to end. it's supposed to be AH3049. so i need to get 3049. 3000 is a given, since it's always going to be at least 3000 rows. i then add COUNTA to count how many of the cells in AH3001:AH10000 are filled. that will give me 50 counts. 1 extra because your formula ended in 3050. so i minus 1
if it's not that straightforward, you can play around with the portion on how to get the 3049. some patterns i noted for you to play with:
1. every set of Column AE values occupies 3 rows. for eg. AE3001:AE3003. so you can use a COUNTIF to find out how many of these are more than 0:
=COUNTIF(AE3001:AE10000,">0")
there are 13 of them. since they occupy 3 rows each, multiply by 3. that gives you 39 rows.
=COUNTIF(AE3001:AE10000,">0")*3
2. from row 3040 (after the last entry) to the 1st Shift text is 10 rows. so you can use the above COUNTIF + 10. final formula would be:
=$AD$3001:INDEX($AH:$AH,3000+COUNTIF(AE3001:AE10000,">0")*3+10)
3. if you will have another set where there is like a "2nd Shift xxxx", then you would have to make the 10 rows a variable too. use COUNTIF to find out how many times "Shift" appears
=COUNTIF(AF3001:AF10000,"*shift*")
similar to the other COUNTIF, this one occupies 10 rows each time it appears. so multiply by 10
=COUNTIF(AF3001:AF10000,"*shift*")*10
final formula:
=$AD$3001:INDEX($AH:$AH,3000+COUNTIF(AE3001:AE10000,">0")*3+COUNTIF(AF3001:AF10000,"*shift*")*10)
as you can see, there are too many factors. and since i made the effort to explain to you, i hope you can make the effort to figure it out
Bookmarks