+ Reply to Thread
Results 1 to 9 of 9

Replace a string of numbers in a macro with the value in a cell. Filtering several items

  1. #1
    Registered User
    Join Date
    10-08-2022
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365 Version 2108 MSO (16.0.14326.21142) 64 bit
    Posts
    4

    Replace a string of numbers in a macro with the value in a cell. Filtering several items

    I made this macro by recording it:

    Please Login or Register  to view this content.
    The string in the Array should be substituted by the value in H5 in a different sheet in the same workbook

    H5 = "5000165", "5000746", "5000831", "5000882", "5001059"

    So I tried this:

    Please Login or Register  to view this content.
    The MsgBox return the value in cell H5, but the filter returns no values at all.
    Is it possible to do this another way ?
    Tried to change the text string in cell H5 and making it semicolon delimited, did not help ?
    Also tried to change the text string in cell H5 so it looked like this: 5000165, 5000746, 5000831, 5000882, 5001059, still same result
    Last edited by LarsStaun; 10-08-2022 at 12:52 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code. This is one of the rules that you just agreed to adhere to!!

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note:since you're new here.... I've doen it for you, this time.)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    10-08-2022
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365 Version 2108 MSO (16.0.14326.21142) 64 bit
    Posts
    4

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    Thank you very much

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    Thanks! I can't help, sorry. I know sweet FA about VBA, but others will be along soon.

  5. #5
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    Well, with this one liner.
    Sheet "test" in this example is the sheet where the values in H5 are.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-08-2022
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365 Version 2108 MSO (16.0.14326.21142) 64 bit
    Posts
    4

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    Thanks, but it gives the same result. The filter does not select any values. I have made a short file to demonstrate.
    Attached Files Attached Files
    Last edited by LarsStaun; 10-08-2022 at 02:23 PM. Reason: Attachment missing

  7. #7
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    The currentregion is not correct in your sample
    Problem is the double quotes on sheet 2.

    Try

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-08-2022
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365 Version 2108 MSO (16.0.14326.21142) 64 bit
    Posts
    4

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    Removed the double quotes and voila! it works with your first suggestion
    Thank you very much for your help

  9. #9
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Replace a string of numbers in a macro with the value in a cell. Filtering several ite

    You're welcome!

+ 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. [SOLVED] Find and Replace multiple text/numbers within string
    By Chgardne in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-08-2020, 10:56 AM
  2. Find and replace parts in string with words, numbers from a table
    By moosmahna in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2017, 11:54 AM
  3. Excel Macro filtering only 1st item out of multiple items from the source data
    By zipperzipped1204 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2015, 02:37 PM
  4. Recording a Macro with Filtering and variable cell numbers
    By ashley72788 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-23-2015, 03:53 PM
  5. Replace Items in a string with corresponding values from an array
    By william1404 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-25-2014, 09:22 PM
  6. Replies: 2
    Last Post: 08-23-2012, 04:58 PM
  7. A Macro to replace a string in a cell with a string from another cell???
    By Plica05 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2005, 04:23 AM

Tags for this Thread

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