+ Reply to Thread
Results 1 to 13 of 13

Wildcard search in VBA doesn't seem to work on some data

  1. #1
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Wildcard search in VBA doesn't seem to work on some data

    Hello

    I have data which consists of part numbers with a mix of letters and digits, i.e. 4199E711 or 320/A1999 and some just numbers. To prevent what I understand to be an Excel "bug" from change this type of data to scientific format, I have forced this data to be stored as text. I believe it is the "E" between the digits that Excel seems not to like. So I now have data with lots of green triangles in the lefthand corner of some cells. however part numbers like 320/A4132 is fine. I have a userform which searches this data and populates a listbox within the userform. I have used a wildcard search criteria as part of an advance filter. This seems to work Ok but not if I search "320"... nothing is found. This is the code which I have followed as part of an online tutorial and adapted to my data (I am new to VBA):

    Please Login or Register  to view this content.
    Would be grateful of any help.
    Regards
    Amita
    Last edited by Amita68; 09-22-2017 at 07:41 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Wildcard search in VBA doesn't seem to work on some data

    To prevent exponential values you van also format the cells as number with no decimals, text is not that 'user friendly'

    By wild cards, which?
    The vba form the userform does not help because I do not know hat textsearch is.
    If you look into part of a text you could use Instr() but then that dos not work nicely with .Find.
    I guess the file with dummy data and the userform and macros will be a better option to get help and a correct answer or at least put you on the right track
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Re: Wildcard search in VBA doesn't seem to work on some data

    Hello
    Thank you for taking the time to read my post.
    By WildCard I mean that it searches for partial data within the specified range.
    I have adjusted my file to show dummy data but keeping the formats and retaining the concept. However, the file is almost 20mb and am unable to upload. Could you please suggest another method for sending the file?
    Regards
    Amita

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Wildcard search in VBA doesn't seem to work on some data

    You could reduce the number of rows and make sure that empty ranges are not included.
    In the worksheets press Shift+Ctrl+End and it will take you to the last cell.

    Check if this is really the last filled cell,
    If not delete all rows form the last filled row all the way down and from the last column all the way to the right.
    This will reduce your file

    Without an idea of a sample and how you're searching is difficult to advice

  5. #5
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Re: Wildcard search in VBA doesn't seem to work on some data

    Hello
    I did what you said and it has reduced the file size, thank you.
    Just to give you some background. We have no system and I have been tasked to put something together where there is one place to search parts, who buys them, their alternative customer numbers, who supplies the raw casting and inventory control, etc. We are a subcontract company. We have Customers with several divisions, each division trades separately and could order the same part under different POs. Hopefully this will explain why some parts appear as duplication. The project is still work in progress and is nowhere near finished. In adjusting my data to remove sensitive data, I'm not now sure whether my original problem exists. I would however be interested in your opinion. The Parts userform searches/edits and adds parts using all search options. I'm not sure whether this is working without fault in all search options or picking out the data. The customer and suppliers forms are fine but need to be populated with address and contact info which I intend to do at a later stage. I am working on the inventory stage. This is proving the most difficult as I'm not sure how to approach this. You will see from the data sheet, that because of the mix of letters and numbers I have had to force the format to text otherwise Excel changed some info to scientific format. Again, please bear in mind I am very new to VBA and have just looked up info and copied, etc.


    regards
    Amita
    Attached Files Attached Files

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Wildcard search in VBA doesn't seem to work on some data

    I am using Office 2010 and Office 2016 but do not have the reference MSCOMCTL2.OCX this is probably because you are using a Office 64-bit and I am not, but I canged the fererence to MSCOMCTL.OCX to at least take a look and see what you macro's do.
    One command is not recognized and that is Clear ??? it's supposed to clear search data but I do not see how Clear would know what to Clear so my guess is that this incorrect in you VBA code.
    apart from that, you mention that searching for 320 doesn't do anything.
    Well, it does here

    Another thing, you do not need to format long numbers as text, format them as number without Decimals and then they will show as long integers.

    So back to your search issue, no problem so far here.
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Re: Wildcard search in VBA doesn't seem to work on some data

    Hello
    Thank you for a quick response.
    This is what I feared, in adjusting my data to hide sensitive data my original problem is now gone. In my original file if I search 320 I only get one result where the line ID shows "1320" and nothing else. However if I search "320/" then all the data I expect to show does show up. I can accept with this.
    You're right, the Clear sub is missing. It is a sub that clears all controls and somewhere along the line it's stopped working or "misplaced". I should be able to correct this.

    With reference to the scientific format please see the link below.

    HTML Code: 
    Thank you again for your help.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Wildcard search in VBA doesn't seem to work on some data

    Well okay.
    About the scientific notation, I do not like the apostrophe and is leaves that little green triangle at the top left.
    If I know that I'll get a scientific notation and I n=know that there are no decimals I always format those cells as Number with 0 decimals even if they do contain text or like you have 320/3434242
    it still works, only align then all Left so that they're all the same.

  9. #9
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Re: Wildcard search in VBA doesn't seem to work on some data

    Hello again.
    My problem with the formatting lies with part numbers with "E" with numbers either side, i.e., 4417E221. Even if formatted as number with no decimals, I still get something other that. I agree, I don't like the green triangles, either but something I have to live with I guess.
    Thanks again for looking at this for me. Much appreciated.

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Wildcard search in VBA doesn't seem to work on some data

    Here's the file with the formatting changed

    What is the problem then?
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Re: Wildcard search in VBA doesn't seem to work on some data

    Try putting in 4134E071 and see what you get. It doesn't work for me.
    It seems fine when there is another character or letter in addition to the E separating the digits. I have resigned to the fact this is an Excel bug. Thanks again.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Wildcard search in VBA doesn't seem to work on some data

    Okay
    Here's the result
    Attached Images Attached Images

  13. #13
    Registered User
    Join Date
    08-18-2017
    Location
    Leicester, England
    MS-Off Ver
    Office 2013 & 365
    Posts
    54

    Re: Wildcard search in VBA doesn't seem to work on some data

    We seem to be at cross purposes. I was referring to the formatting errors for part numbers such as 4134E071 in my data sheet changing to scientific etc. Formatting this to number without decimals does not seem to work for me, the cell displays 413400000000000000000000000000000000000000000000000000000000000000000000000. Forcing this to text and searching this in the userform is not a problem. When I opened your formatted sheet, it looked fine without format errors but as soon as I enabled content the errors reappeared. I have resigned to this being an Excel issue. My problem as per my previous post is with part numbers which are automatically sorted as text without formatting errors such as 320/???? and that this did not show in the search in the userform when keying in search "320". I also said that in trying to create fictitious data this problem seems to have disappeared in the fictitious workbook and shows up in the userform but does not in my genuine workbook. I can live with this as I just need to enter a search for "320/" and not just "320"

+ 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. Data validation doesn't work
    By SuuzyQ in forum Excel General
    Replies: 4
    Last Post: 04-14-2016, 08:18 AM
  2. [SOLVED] Work around for Run-time Error 445: Object Doesn't Support This Action (File Search)
    By JPDutch in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-05-2013, 08:48 AM
  3. Replies: 5
    Last Post: 05-13-2013, 06:23 PM
  4. [SOLVED] Why doesn't a wildcard work for a workbook name compare?
    By garygomes in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-18-2012, 08:26 PM
  5. Vlookup doesn't work with imported data
    By surfthenet in forum Excel General
    Replies: 2
    Last Post: 08-24-2010, 10:18 AM
  6. Excel 2007 : search data using wildcard and sum it
    By eddy82 in forum Excel General
    Replies: 1
    Last Post: 06-03-2010, 06:23 AM
  7. Data Validation doesn't work on 1 sheet only
    By lunker55 in forum Excel General
    Replies: 4
    Last Post: 02-25-2005, 02:06 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