Link to home
Start Free TrialLog in
Avatar of Dan Purcell
Dan PurcellFlag for United States of America

asked on

Looking to be able to pull a set number of zip-code's from an Excel Worksheet using a macro

Looking for a Macro in Excel. I have a workbook with around 80,000 address's in the state of Iowa. I would like to be able to input a zip-code into the macro and the quantity copied to sheet 2. Preferably the address's pulled based on that quantity would be randomized. I've attached a demo list.

In a perfect world I'd be able to enter up to 3 Zip-Codes and randomly pull the requested quantity. This is a list I'd refer to often as this client has blood-drives at different locations across the state. They supply an internal list, after I dedup and remove the bad address's we often need a few hundred more address's in that drives zip-code.

Thanks in advance!
Excel-Demo-List.xls
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

What do you mean by "the quantity"?
Avatar of Dan Purcell

ASKER

So lets say there are 885 address's that are zip-code 50511. I would like to pull a quantity that I determine when I run the macro. So in this case let's say I want 400 randomly pulled from the 885. I was hoping when I launch the macro I would get a dialog box asking for zip-codes and the final quantity to be copied to sheet two. I would want the entire address copied to sheet 2.

Thanks
OK, be back soon.
Try this. Click Ctrl+Shift+Z. (I could also add a button)
29118528.xlsm
Wow, that's what I want. If my customers list isn't exactly the same as the demo ( zip-code in column I instead of G  and/or an address2) where in the macro would I change that. I took a quick look but didn't want to mess it up
You'll find "G" (including the quotes) in 5 places. Change them all to "I". Let me know if you'd like me to add some documentation to the code
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
Thanks for your help!
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
              Experts Exchange Top Expert VBA (current)