+ Reply to Thread
Results 1 to 4 of 4

VBA to replace "q" at the end character in column F with "nothing"

  1. #1
    Registered User
    Join Date
    09-10-2021
    Location
    Svalbard, Norway
    MS-Off Ver
    2020
    Posts
    4

    Unhappy VBA to replace "q" at the end character in column F with "nothing"

    I want to replace "q" which is the end character for few lines in column F with "nothing".
    To do this I have written below code which first filters column F for lines with "q" as end character.
    Next macro should automatically drop down and select all the lines in that column and replace "q"
    It is not working. My code filters for "q" but then does not select all the rows with such condition and replace. Also data is dynamic. So I am not sure which one will be the first row with "q" filter on. Hence i have given a form for selecting that cell.

    Could you tell me where i am wrong?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jeffreybrown; 09-19-2021 at 03:00 PM. Reason: New title

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: What is wrong with my code?

    If you just want to replace ALL rows which contain letter "q" in column F,
    then you can just do like this : (no need to filter - no need to select)
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-10-2021
    Location
    Svalbard, Norway
    MS-Off Ver
    2020
    Posts
    4

    Re: What is wrong with my code?

    Quote Originally Posted by karmapala View Post
    If you just want to replace ALL rows which contain letter "q" in column F,
    then you can just do like this : (no need to filter - no need to select)
    Please Login or Register  to view this content.
    Thanks for the quick response.
    Actually there are many rows in which "q" is present.
    However i want to replace only those rows in which "q" is at the end, for example 12345q (to be replaced as 12345) and not at the beginning or anywhere else such as q12345/123q45

  4. #4
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: What is wrong with my code?

    Quote Originally Posted by erzengel View Post
    Thanks for the quick response.
    Actually there are many rows in which "q" is present.
    However i want to replace only those rows in which "q" is at the end,
    Sorry I was mistaken to get what you mean in your OP.

    Please Login or Register  to view this content.
    The code loop to each cell with value in column F
    and check if the last char of the current looped cell is "q",
    if the last char is "q" then it replace the "q" with blank
    if the last char is not "q" then it skip the replacement process.

    But if you mean like this
    q45derfqqqatq ---> q45derfqqqat

    then don't use the code above, but this one :
    Please Login or Register  to view this content.
    The code above remove the last char if the last char is q.
    Last edited by karmapala; 09-19-2021 at 04:12 AM.

+ 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] Please, help me with the code for Similarity Factor Calc. My code gives wrong number.
    By Invictus1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2015, 09:52 PM
  2. Something wrong with my code
    By dinker454 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2013, 07:03 PM
  3. what is wrong with this code- error from vba code
    By punna111 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2013, 03:14 PM
  4. Code for email alerts from excel isn't working, wrong code possibly?
    By jessthorogood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 01:45 AM
  5. Wrong line of code banned me out and can't access vba code...
    By albertc in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-14-2012, 02:41 PM
  6. What is wrong with this code?
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-12-2005, 04:05 PM
  7. [SOLVED] What's wrong with my code ?
    By christophe meresse in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 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