+ Reply to Thread
Results 1 to 8 of 8

Question regarding vba search capabilities

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    957

    Question regarding vba search capabilities

    I would be greatly appreciative with any assistance or advice one could give regarding the following: I've attached a small sample workbook of what I'm trying to accomplish as it pertains to searching for individual phone and/or direct connect records. I could potentially have thousands of different phone numbers (some of which could be matching over several months worth of data) as well as direct connect numbers. Using a simple filter button for any particular column would contain to many numbers for me to easily identify the number I'd be looking for to filter and would be very time consuming. I started to create a user form for what I'd like to open up via a macro type activation button, which would allow me to search either by phone number or direct connect number. I however am not very knowledgable with vba to get this to work and any assistance would be greatly appreciated. My thought, if possible would be to have whatever number (either phone or direct connect number) that is typed in the user form and after the search button his clicked, attempt to locate the number via the filtering function and if found automatically filter it by unchecking all of the others non-applicable numbers in either column B or C. Due to having incoming and outgoing numbers the code would have to look at data in columns "B6 and below" and "C6 and below" while maintaining the integrity of the other column data affiliated with each number. I hope this makes sense!

    Thanks to anyone willing to take the time to look at this!
    Attached Files Attached Files
    Last edited by lilsnoop; 02-08-2009 at 04:59 PM.

  2. #2
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: Question regarding vba search capabilities

    Hi
    Your requirement is not clear to me. Can you give an example?
    Ravi

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    957

    Re: Question regarding vba search capabilities

    Hi ravishankar! Thanks for looking at this. I was hoping to have a search window that I could either type in a phone number or a direct connect number, that when applied would automatically look in columns B & C for any matching number. If no matching phone number or direct connect number is found then a msg would pop up and say something to the effect "no such number located", etc. If the number is found I would need to have a report similiar to being filtered that would allow me to see all of the incoming & outgoing entries affiliated with the number being searched. This spreadsheet could contained 50,000 phone numbers many of which could be similar numbers in either column B or Column C. I need to be able to search the number and see how many times this number shows up as being either an incoming or outgoing call and maintaing the integrity of the other data as well affiliated with that row; i.e. I'll need to be able to see the duration of the call, date & time, etc too. I don't know if this is possible or not. Maybe the vba code could copy & paste all the filtered data to another sheet, which would be replaced upon the next search... I'll understand if this is way to complicated. Thanks again for any help you might be able to offer or suggestions that might make what I'm trying to accomplish even easier.

    As an example: If I wanted to look up a phone number of 12699348125 I would type this in a search (userform created) and it would possibly first look in column B6 & below for any matches. If matches are found it would automatically filter for this number only and copy and paste in another sheet. It would then unfilter column B and then look in column C for any matches for this particular number too and if found then copy and paste in the new sheet under the previously coped data. Afterwards it would unfilter column C and would then be available for another search criteria. The data to be copied would be the entire row from A to H for whatever number is searched. I hope this helps...
    Last edited by lilsnoop; 02-07-2009 at 11:06 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    957

    Re: Question regarding vba search capabilities

    I've attached a new zip file example. The user form on this example allows for a search window. The buttons (upon which I'll need help with) would theoritically search for the specific phone number or direct connect number in the individual columns specified. If the numbers are found it would automatically filter that number. This would eliminate needing to copy and paste, etc. Any chance something like this could work? and if so could anyone help me with it?
    Attached Files Attached Files

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Question regarding vba search capabilities

    Hello Lilsnoop,

    I have add the following macro to your button. It will search for the terms you type into the UserForm and copy the rows of each result on "Sheet2". Each time the macro runs the data will be appended to "Sheet2". The macro returns all exact matches it finds.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Question regarding vba search capabilities

    Leith has beaten me to it, but in case you're interested here is an AutoFilter approach which runs when the "Search B" button is pressed. It does B&C and doesn't require the other buttons as I assumed the column in which the number was found is not of interest (but could be adjusted if needs be).
    Right click on the button, view code and paste this in:
    Please Login or Register  to view this content.
    This goes in a normal module:
    Please Login or Register  to view this content.
    Also, I deleted the contents of A4 as needs to be a clear space between the filter range and other cells. You could of course insert a row in which case the filter should be set at A6.
    Last edited by StephenR; 02-08-2009 at 07:10 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    957

    Re: Question regarding vba search capabilities

    Leith-You are the Man!! Thank you very much!!

  8. #8
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    957

    Re: Question regarding vba search capabilities

    Stephen, I appreciate your input as well! Each phone company has a slightly different format so one code may work better than the other! Thanks so much for both of your input!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1