Yes, that does make sense. I am familiar with the concept of running 
"For..." code from the bottom up, because records will be deleted.

As you mentioned, the goal would indeed be to have a selection once some 
cleanup has already been done. I've put an example below, with the action 
we're discussing indicated by "******":
-  the initial data set has 1,000 records in columns A:P
- the user indicates which client they want to work with (located in column 
A)
- VBA deletes 600 records not belonging to that client
- in the remaining 400 records, there are 275 unique locations (located in 
column C)
- ****** I want to bring up a box that lets the user select which of those 
275 unique locations they do not want to include
- They check the box next to 40 locations
- VBA deleted 75 records belonging to those 40 locations, leaving 235 
unique locations and 325 records belonging to them


FYI, I copied your macros over, and ran them just to see what would happen. 
Both gave me "Run-time error '424': Object required":
- Private Sub Btn_Delete_Click() on line 5: "For nRow = 0 To 
Form_Records.Lst_Type.ListCount - 1". 
- Private Sub UserForm_Initialize() on line 11: 
"Form_Records.Lst_Type.Clear"
    
I imagine it's not the code, but rather the fact I haven't yet tailored it 
to my data. But I wanted to let you know.




>
>
>
> Now:
> you've mentioned that you want to run this cleanup routine after a PORTION 
> of the data has been processed.
> Does that mean that you only want to list/address the records you've 
> processed?
> That is:
> - If you have 1000 records
> - after 200 records, the userform obtains unique values FROM ONLY THE 200 
> RECORDS.
> - You make your selections and the macro button deletes the selected 
> records, but ONLY FROM THE FIRST 200
> - Then the macro proceeds.
>
> If that's how you want it to go, I have a "caution".
> -You've processed 200 records (the "pointer" is now at record 201)
> -You select and delete selected record values, which deletes 10 records.
>
> Your pointer is still at record 201, but the previous record 201 has been 
> moved to record 191.
> So, when you proceed, your macro would effective skip 10 records.
>
> That's the reason that in my macro, you'll notice the Delete loop starts 
> at the end and moves UP
>
>     For nRow = nRows To 2 Step -1
>
> You'll want to do the same when you delete from your first 200 records.
>
> does that make sense?
>
> *Paul*
> -----------------------------------------
>
>
>
>
>
>
>
> *“Do all the good you can,By all the means you can,In all the ways you 
> can,In all the places you can,At all the times you can,To all the people 
> you can,As long as ever you can.” - John Wesley*
> -----------------------------------------
>
>
> On Monday, October 17, 2016 10:07 AM, kalimotxo <jamison...@gmail.com 
> <javascript:>> wrote:
>
>
> Hi Paul,
>
> I apologise for the confusion. You are right I did not fully comprehend 
> yet what you were proposing, so was probably early in forming an opinion on 
> part of it!
>
>  Let me briefly describe the situation I want to accomplish.
>
> 1) I have a sheet of data that I run a macro on.
> 2) At a certain point, let's say after 20% of the code has already 
> executed, I will want the macro to call up a message box of unique 
> locations (I have no problem getting the list made & removing duplicates)
> 3) The user will scroll through box, clicking a check mark next to the 
> ones they want to select.
> 4) They will then hit the button in the message box, at which point the 
> code will continue to the next step, which is deleting any record with a 
> location matching one of the checked ones.
>
> Question: are the two sub() you proposed complementary, and I need to 
> integrate both of them, or are they two different options for the same 
> thing? As I mentioned on Friday, this is completely uncharted territory for 
> me.
>
> Thanks again!
>
>
> On Monday, October 17, 2016 at 6:43:47 AM UTC-5, Paul Schreiner wrote:
>
> You response is a LITTLE confusing, but it may be that you didn't read the 
> entire post.
>
> Your original question was:
>
> *I'm running a macro to process some data over several columns. At a 
> midway point of the code, I need the macro to bring up a list of possible 
> names. The user then can check the ones they do not want, **click OK**, 
> and then the macro will go on to delete all records connected to that name.*
>
> *The names are in column A, and repeat.*
>
> *How can I call up a list of all unique names in column A, with a check 
> box available for the user to scroll through and pick all the names they 
> wish to?*
>
>
> In my response, I said:
>
> I created a userform (called Form_Records)
> that contained one listbox called Lst_Type
> and a button called "Btn_Delete".
>
> You can call the button "Btn_OK" and have the caption read "OK",
> so that once the user selects the keywords to remove, they then "Click OK".
>
>
> Basically, the approach is:
> 1) Read through data and collect "unique" values from column "A"
> 2) Open a userform and the values to a listbox.
> 3) Once items are selected, the "OK" button will then store list of items 
> to be deleted.
> 4) Cycle through data and delete rows containing selected keywords.
>
> The technique (or "trick") here is in collecting of the list of unique 
> values.
> The most common method is to create an array and add the items to the 
> array.
> However, to check to see if the item is already in the array requires to 
> loop through the array:
>
> Flag_Exists = false
> For inx = 0 to ubound(strArray)
>   if (NewItem = strArray(inx)) then 
>      Flag_Exists = true
>      Exit For
>   end if
> next inx
> if (not flag_Exists) then
>   'Add Item to strArray
> end if
>
> This works for small data sets, but if you have 5000 rows, the code has to 
> loop through the array 5000 times!
> (you can do things to reduce the number of iterations, like: declare the 
> array without a "size" then redim the array and increase the size each time 
> you add an item, or declare the array with a size larger than the 
> anticipated number of unique values and initialize the array with blanks. 
> Then break out of the above loop when the array value is blank.
>
> I like using the Dictionary Object. It eliminates the need for looping 
> through an array, checking values, and you don't have to anticipate the 
> maximum number of values.
> It's be REALLY COOL if the object had a "sorted" property, but I guess you 
> can't have it all!
> *Paul*
> ------------------------------ -----------
>
>
>
>
>
>
>
> *“Do all the good you can,By all the means you can,In all the ways you 
> can,In all the places you can,At all the times you can,To all the people 
> you can,As long as ever you can.” - John 
> Wesley*------------------------------ 
> -----------
>
>
> On Friday, October 14, 2016 4:39 PM, kalimotxo <jamison...@gmail.com> 
> wrote:
>
>
>
> Hi Paul, this sounds pretty good. I'm new to  working with these type of 
> objects, so I'll have to read through clearly. One thing I notice, if I 
> understand your code correctly, is that I do not want to have to click a 
> button to run the code, but rather have it in the middle of my sub(), or 
> else call it from my sub(). But once I have it working, I can probably 
> figure that out.
>
> Work done for the day, so I'll let you know Monday if it was successful. 
> But I wanted you to know I appreciate the prompt response!
> -- 
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
> https://www.facebook.com/ 
> discussexcel <https://www.facebook.com/discussexcel>
>  
> FORUM RULES
>  
> 1) Use concise, accurate thread titles. Poor thread titles, like Please 
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice 
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security 
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>  
> NOTE : Don't ever post confidential data in a workbook. Forum owners and 
> members are not responsible for any loss.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to excel-macros...@ googlegroups.com.
> To post to this group, send email to excel-...@googlegroups.com.
> Visit this group at https://groups.google.com/ group/excel-macros 
> <https://groups.google.com/group/excel-macros>.
> For more options, visit https://groups.google.com/d/ optout 
> <https://groups.google.com/d/optout>.
>
>
>
> -- 
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
> https://www.facebook.com/discussexcel
>  
> FORUM RULES
>  
> 1) Use concise, accurate thread titles. Poor thread titles, like Please 
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice 
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security 
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>  
> NOTE : Don't ever post confidential data in a workbook. Forum owners and 
> members are not responsible for any loss.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to excel-macros...@googlegroups.com <javascript:>.
> To post to this group, send email to excel-...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to