+ Reply to Thread
Results 1 to 7 of 7

Simple VBA to look for value

  1. #1
    Forum Contributor
    Join Date
    12-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    119

    Simple VBA to look for value

    Hi
    I'm new to VBA, and I have already tried to google this, though I can't find something that fits to my problem (or that I'm able to adjust to my problem).

    The problem is simple: I have a list of values and I need to checke if these values appear in one of the other worksheets. The problem is that the sheets are unstructured, so in some sheets, the value could be macthed column D, in other sheets in column E. But the value to search for will always be in the range A:H in the underlying worksheets, if there is a match.

    So.. The code should search for a value and return where the value appear(s).. Please see the attached simplified file.



    I really hope that someone can help me.
    Attached Files Attached Files
    Last edited by Ztv; 04-22-2014 at 03:46 PM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Simple VBA to look for value

    hi,

    This code:
    Please Login or Register  to view this content.
    will work for your example workbook...

  3. #3
    Forum Contributor
    Join Date
    12-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Simple VBA to look for value

    @raguldguy - thanks! As you say, the code works perfectly for my workbook. I'll try to implement it to my original file tomorrow .

    Sorry for the late reply, I had to go for a meeting earlier.

  4. #4
    Forum Contributor
    Join Date
    12-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Simple VBA to look for value

    @ragulduy: How do I make the code to ignore small letters/capital letters, spaces, etc.? For example: ABC.. if abc appears in another sheet, it should be a match.. Also for aBc or a bc.

    EDIT: It can already distrinquish between small letters and capital letters, now I just need it to ignore spaces/embedded spaces
    Last edited by Ztv; 04-23-2014 at 03:42 AM.

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Simple VBA to look for value

    My suggestion would be to clean up the data to get rid of the spaces first, using the find method, I think the only option would be to use wildcards but that would probably make the search too "fuzzy" and end up picking up incorrect entries.

    You could change it to loop through and test every cell but it would take too long I think.

  6. #6
    Forum Contributor
    Join Date
    12-08-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Simple VBA to look for value

    Yeah, you're right. I was thinking about to first run a loop that would "clear" the lookup values. But if that should work, this should be done in all sheets.

    But I totally agree with your "cleaning up"-argument. It just simple takes too much time in this case. As I told the one who asked me to do this: Garbage in, garbage out.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Simple VBA to look for value

    Can you not do find and replace? find " ", replace with ""?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 12-07-2012, 11:49 AM
  2. A simple question requiring a simple answer
    By Pedros in forum Excel General
    Replies: 3
    Last Post: 07-18-2006, 06:45 AM
  3. Simple Simple Excel usage question
    By BookerW in forum Excel General
    Replies: 1
    Last Post: 06-23-2005, 05:05 PM
  4. Make it more simple or intuitive to do simple things
    By Vernie in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-16-2005, 12:06 AM
  5. Posting data from a simple form to a simple database
    By clacka in forum Excel General
    Replies: 0
    Last Post: 01-30-2005, 04:37 PM

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