+ Reply to Thread
Results 1 to 6 of 6

Macro to Remove "PK" From a String

  1. #1
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Macro to Remove "PK" From a String

    Good Morning Everyone,

    Hope you all are staying healthy!

    In Column A I have approximately 100 rows of text string. Around 25 of them look like this(PK 280 0109045 000-099)while the remainder look like this(098 0792545 000-019). What I need to do
    is delete the "PK" portion of the strings with a macro. Unfortunately I can't use LEN -2 because it would remove the first 2 characters from the rest in the range.

    Any help would be appreciated!

    Thanks,
    D

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Macro to Remove "PK" From a String

    No need for VBA. Just use this:

    =IFERROR(SUBSTITUTE(A1,"PK ",""),A1)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Re: Macro to Remove "PK" From a String

    Thanks Ali. The problem with that is the data is every changing and in different rows. If I can insert that formula to run in a macro on range A:A that should work.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,297

    Re: Macro to Remove "PK" From a String

    Maybe this helps.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Re: Macro to Remove "PK" From a String

    Bakerman2,

    That is the ticket! Thanks a bunch!

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,297

    Re: Macro to Remove "PK" From a String

    You're welcome and thanks for rep+.

+ 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. Need Help w/ Formula to Remove "00s" at End of Results String
    By jasonb9 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-14-2018, 04:04 PM
  2. How can i remove remove the last "?" from a cell/url string?
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-21-2015, 02:13 PM
  3. Replies: 1
    Last Post: 08-15-2014, 06:00 AM
  4. [SOLVED] VBA help needed to remove all "/" then replace with "-" from cell "B3"and "B5"
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2014, 02:11 PM
  5. Macro to remove " around a string of data
    By CM03486 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2013, 12:49 PM
  6. [SOLVED] UDF to remove "equivalent" expressions from a ";" delimited string
    By dredwolf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2012, 07:25 PM
  7. Macro to trim a cell and remove string "THRU"
    By Rocker7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2010, 01:24 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