Link to home
Start Free TrialLog in
Avatar of Pedro
Pedro

asked on

maximum of "X" numbers from same "deci".

The idea is to create a script that allows a maximum of "X" numbers from same "deci". A deci is defined as numbers from 1-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-89, and 90-99,

There should be:

1) a prompt would ask for input of "Maximum numbers allowed from same deci" or something similar. If the input is one (1) then
2) ask to click on any cell that contains numbers to be processed then
3) sheet "Numbers_3" would be edited as follows:

 This process should be able to be repeated for any sheet similar to "Numbers_3"

User generated imageThe picture shows items in RED that should be removed they all contain more than one number from the same deci. The sample numbers that should remain are 3, 7, 10, 20, 30 since only 3 and 7 are from same deci. 3, 7, 10, 20 and 29 are shown red since it contains 3 and 7 from same deci plus 20 and 29 from same deci. Thus it does not meet the criteria.
AllowMax_X_fromsameDeci.xlsm
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

No workbook
Avatar of Pedro
Pedro

ASKER

I had to use a different file. Apparently it did not allow my original due a max 50MB per file.

 Please make a separate script for this since I'd like to run it separate from any other scripts.

If you save the workbook as an xlsb file rather than an xlsm file it will be a lot smaller. With that in mind do you want to post the one that was >50MB?

And by the way did you try the updated file that I posted in your previous question? It's an xlsb file.
Avatar of Pedro

ASKER

No, this one should be fine since we only need to test on one worksheet and it contains the same data I have for the first sheet and second sheets.


Yes. It worked as intended for the full set after editing as you specified. Thank You!

What happened to the picture? I know I saw it but it doesn't seem to be there now.
Also, is this different in your mind than
2) ask to click on any cell that contains numbers to be processed then


this?
2) ask to activate (select) one of the Numbers_n sheets that contains numbers to be processed then
Avatar of Pedro

ASKER

Re-embedded the picture. I can see the file and the picture.


Either will work as long as it processes items on one (1) sheet at a time and only for the "selected sheet"

In this workbook run the RemoveInvalidDecis macro. It is glacially slow. The worksheets have over 800,000 rows and it pushes my system to its limits but maybe you'll have better luck. When it starts to run the status bar (lower left-hand corner) will display the row it's processing every 50,000 rows. You'll see the number decrease because it starts at the bottom. When it's done it will say "Done".
29173241.xlsb
Avatar of Pedro

ASKER

Martin,


It does seem to work but partly. The image below shows some of the same numbers in the original post that should have been removed but are still there after processing. Anything in red or anything similar should not be there after the script is run on a sheet.

Also, I expected it to ask how many "deci's" to remove. I assume you set it at one. Hence, these reds should not be there. Notice that there are two numbers from the 1-9 range and two from the 10-19 range. 


There are many items besides these that should also be removed.

User generated image

My apologies. I didn't fully read the question and so the code assumes that like in previous questions if a deci contains 3 or more then it's invalid. I will fix that and I just had an idea that mey speed it up.
Try this. The rows are now processed top to bottom.
29173241a.xlsb
Avatar of Pedro

ASKER

Runs much faster at 5 minutes  versus 12 minutes previously. But,


1)  I got an error even when I ran it on sheet 3 and sheet 7


User generated image

After I clicked 'Ok" is seems to run as intended. It should be removed without affecting results. Otherwise, it can stay there.


2) The "Maximum in Deci" pop up needs adjusting. The default is "2" which led me to believe that it would allow 2 from any deci. However, it seems to allow only 1. When I change it to 1 it allows zero per deci. This can get confusing. I'd Like to adjust that variable so it's input follows the logic static in my original post.


User generated image


Otherwise, it seems to perform as intended.

Please try this little test program where I set up 6 decis in Numbers_3 and I colored them as I believe they should be (green = keep) if the default of "2" is used. I did not change any code except for removing the code that actually deletes the bad (red) decis. I plan on adding code that does not allow the entry of less than 1 or greater than the  number of cells in the deci (5 in this case).
Pedro.xlsb
To run it more than once you'll need to delete the column that has the Deletes.
Avatar of Pedro

ASKER

Martin,


I ran code "RemoveInvalidDecis" since there were more than 1. 


It seems this script targets more than one number from "same deci" as in my original post. which means it does what was originally intended. I also added additional and it targeted those as well. I colored in orange in the picture below. 


Is there any way to alter the input to match the number of "decis" in the output? In other words, now "2" keeps two number from same deci but it should be "one pair" from same deci as the default. I hope I explained it so you can understand.


User generated image

I don't understand what the difference is between "two number from same deci" and "one pair". Can you show similar decis, one that should be deleted and one that should not?
While waiting for the answer to my question I got the time down to just over 1 minute.
Avatar of Pedro

ASKER

My apologies. If this script works as intended if run on the full combinations, then this question can be closed. I’ll address the other in a different question once I see the results from this script.


let me see the results when you fell you’ve got it done.

ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial