+ Reply to Thread
Results 1 to 9 of 9

Dynamic filter by numbers

  1. #1
    Registered User
    Join Date
    04-26-2016
    Location
    Sweden, Malmoe
    MS-Off Ver
    Office 2013
    Posts
    30

    Dynamic filter by numbers

    Hi.
    I'm new to vba and about the only thing I can do so far is to tweak copied codes.
    Now i have a problem, a simple one.

    Im trying to get a filter searchbox to work. I get it to work when "as string" using:
    Please Login or Register  to view this content.
    To the question: How do i change this code so that it works in another field that contains numbers(material numbers e.g. 78531649)?

    To clarify, I understand that the "problem" is the string function and i have to change it to something else like "integer"
    Last edited by martin.lasses; 05-22-2016 at 06:00 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dynamic filter by numbers

    Hi and welcome to the forum,

    At the moment the code is filtering the 3rd column in Table 1. Change the value 3 in the Field:= line to whichever column contains the material number
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    04-26-2016
    Location
    Sweden, Malmoe
    MS-Off Ver
    Office 2013
    Posts
    30

    Re: Dynamic filter by numbers

    Hi and thx.
    I have tried with only changing the field, but since field 3 is text and the field i now want to filter are numbers i think i have to change the dim from string to soemthing else, maybe integer?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dynamic filter by numbers

    Quote Originally Posted by martin.lasses View Post
    Hi and thx.
    I have tried with only changing the field, but since field 3 is text and the field i now want to filter are numbers i think i have to change the dim from string to soemthing else, maybe integer?
    First of all unless the table has been changed then you should be filtering something other than field 3. i.e. the material number field. I don't think it would make any difference if you left the variable as a string variable since the macro would treat the numbers in the columns as matching the criteria. However given that they are numbers it makes more sense to declare them as numbers. So something like

    Please Login or Register  to view this content.
    obviously change the Field ref to the Material Number column number in the table.

  5. #5
    Registered User
    Join Date
    04-26-2016
    Location
    Sweden, Malmoe
    MS-Off Ver
    Office 2013
    Posts
    30

    Re: Dynamic filter by numbers

    Thx for the fast replies.
    I tried with only changing field, but as soon as i insert a number in the textbox it filters everything (it doesn't match anything)
    When i tried:
    Please Login or Register  to view this content.
    I did rewrite the code you sent me so it looked exactly like the one i posted but with "material" field(6) and with the lmatnumber as long and link to another cell (h10),
    Out of that came an error message of missmacth "error 13".

    This is how the table looks like, material being the column to the far right, field 6.
    (Don't know how to link tables so i'm doing it like this for the moment.)

    Document Sold-to Name 1 SaTy Item Material
    2353111502 40978 Autokeskus Oy YR25 8 7349421
    2353111502 40978 Autokeskus Oy YR25 10 2755054


    Right now i have a filter working for the "name 1" field. With the code posted earlier:
    Please Login or Register  to view this content.
    I hope this extra information might help.
    My amateur suggestions: In previous code it states "Dim strfilter as string", i guess i have to do something similiar with the material but i don't know how?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dynamic filter by numbers

    Hi,

    Maybe it's time to upload the workbook so that we may check in context.

  7. #7
    Registered User
    Join Date
    04-26-2016
    Location
    Sweden, Malmoe
    MS-Off Ver
    Office 2013
    Posts
    30

    Re: Dynamic filter by numbers

    I have been trying. When i press the attachment Icon a small whitw window appears but no Browse function or anything. If i drag the file to the message box it starts to download the file...
    Dont no what to do?

    I have been reading the faq. i cant seem to find the way to post reply button, only get to quick reply.
    Attached Files Attached Files
    Last edited by martin.lasses; 05-22-2016 at 02:23 PM.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dynamic filter by numbers

    Hi

    You should be filtering on field 6, In addition just use
    strfilter = [h1]

    There seems little point using a text box just for that to fill a cell when you could enter directly to H1.

  9. #9
    Registered User
    Join Date
    04-26-2016
    Location
    Sweden, Malmoe
    MS-Off Ver
    Office 2013
    Posts
    30

    Re: Dynamic filter by numbers

    Hi.

    If I only change the field number so it filters field 6 it does not find any result, that has been the problem from the start. The filter excludes or cant match any results.

    Also, when i remove the "*" before and after the [H1] the filter needs an exact match, with "*" in place it filters after each character i enter. For example if i enter "Au" the "Delta" customers dissapear.
    As for the textbox it is for future cosmetic purposes.

+ 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: 1
    Last Post: 12-12-2014, 06:46 AM
  2. [SOLVED] Dynamic filter criteria
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2014, 08:07 AM
  3. [SOLVED] filter long numbers with only exact group of numbers
    By Zentiva in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-25-2013, 06:08 AM
  4. [SOLVED] Dynamic filter criteria
    By momosmile in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2012, 04:08 PM
  5. Dynamic Chart via remote filter?
    By NeoPhyx in forum Excel General
    Replies: 6
    Last Post: 05-26-2010, 12:36 PM
  6. Advanced Filter or Autofilter to filter numbers?
    By odeno in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-08-2007, 12:12 PM
  7. FILTER - how to filter numbers ending with 00
    By jude1234 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-25-2006, 07:29 AM

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