+ Reply to Thread
Results 1 to 7 of 7

Macro not finding finding selected characters in strings

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Macro not finding finding selected characters in strings

    Following code should look at every cell in sheet 1 used range, move any rows where a cell contains one of these four characters: ' or ; or - or ! and delete the blank row in sheet 1.

    It's cycling through the cells correctly, but not finding the characters:

    Please Login or Register  to view this content.
    Any guidance, suggestions or solutions welcome as ever

    Ochimus
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,158

    Re: Macro not finding finding selected characters in strings

    Try incorporating this change
    Please Login or Register  to view this content.

    This works....
    Please Login or Register  to view this content.
    Or perhaps as you are deleting blanks in sheet1 anyway no need to copy....
    Please Login or Register  to view this content.
    Last edited by sintek; 11-11-2017 at 10:53 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Macro not finding finding selected characters in strings

    Sintek,

    Really grateful for the prompt response.

    The only one that seemed to work was the second suggestion, and that never deleted the relevant rows from sheet 1, so i added that to the Code.

    Please Login or Register  to view this content.
    When I ran it, the Macro missed the Hyphen in C5 and the two Hyphens in B8, but then running it again straight away it DOES pick them up, leaving just rows 2 and 6 on Sheet 1, as expected.

    Any ideas?

    Ochimus

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Macro not finding finding selected characters in strings

    Please Login or Register  to view this content.
    Ben Van Johnson

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: Macro not finding finding selected characters in strings

    Quote Originally Posted by Ochimus View Post
    ... When I ran it, the Macro missed the Hyphen in C5 and the two Hyphens in B8, but then running it again straight away it DOES pick them up, leaving just rows 2 and 6 on Sheet 1, as expected.
    1. 'Exit For' is missing:
    2. Deleting a row not here (red) because you are changing the area you are working on (mark the cells and run delete at the end of the macro):
    Please Login or Register  to view this content.
    3. code below:
    Please Login or Register  to view this content.
    you can change to:
    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: Macro not finding finding selected characters in strings

    Well, it's enormous thanks to everyone who responded.

    Trust Excel to provide four totally different solutions to the same problem! Tempting to try each one over a few thousand records and see whether there is any significant difference in speed between the different approaches.

    Ochimus

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,158

    Re: Macro not finding finding selected characters in strings

    When deleting rows one always starts from Bottom to Top otherwise you will be skipping rows...
    Please Login or Register  to view this content.
    Thank you for taking the time to Add to reputation

+ 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. Finding two sub-strings within a string
    By pablowilks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2015, 03:05 PM
  2. Finding two sub-strings within a string
    By pablowilks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2015, 10:00 AM
  3. Replies: 9
    Last Post: 12-21-2012, 04:18 AM
  4. Finding exact words i strings
    By Flabbergaster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2012, 01:48 PM
  5. Error 91 while finding strings
    By spammy2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2012, 01:33 PM
  6. Macro for finding out all non-keyboard characters and symbols in a sheet
    By Merry in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2008, 04:26 PM
  7. Finding differences in strings
    By tchezick in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2005, 11:55 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