+ Reply to Thread
Results 1 to 5 of 5

VBA to Remove 2nd & 3rd Characters from a Range of Cells

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    20

    VBA to Remove 2nd & 3rd Characters from a Range of Cells

    Hi All,

    I have a list of hundereds of product codes which all start with a letter followed by 00. For example J007329.

    I would like to remove the double zero (leaving J7329) without having to manually correct each cell. Is this possible?

    Thanks
    JD

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: VBA to Remove 2nd & 3rd Characters from a Range of Cells

    John_Day83,

    You did not say what column, and starting cell your data is in.

    You could adjust the BOLD code in the macro to suit your requirements.

    If you have a lot of data, I could re-write the macro to use arrays in memory that would be extremely fast. But, I will need the column and starting cell information.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the Remove2nd3rdDoubleZero macro.
    Last edited by stanleydgromjr; 02-09-2013 at 09:49 PM.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: VBA to Remove 2nd & 3rd Characters from a Range of Cells

    John_Day83,

    This version of the macro is very fast.

    You did not say what column, and starting cell your data is in.

    You could adjust the BOLD code in the macro to suit your requirements.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the Remove2nd3rdDoubleZeroV2 macro.

  4. #4
    Registered User
    Join Date
    07-24-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: VBA to Remove 2nd & 3rd Characters from a Range of Cells

    Cheers stanleydgromjr,

    This worked a treat, thank you for your time & knowledge.

    JD

  5. #5
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: VBA to Remove 2nd & 3rd Characters from a Range of Cells

    John_Day83,

    Thanks for the feedback.

    You are very welcome. Glad I could help.

    Come back anytime.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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