+ Reply to Thread
Results 1 to 7 of 7

Remove hyphens and period and add number 2 to beginning of string

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    Delaware, OH
    MS-Off Ver
    Office 2019/Office 365
    Posts
    65

    Remove hyphens and period and add number 2 to beginning of string

    I am pretty new to VBA however I am attempting to remove the hyphens and the period from 030-0008-5303.00. All numbers in the Sheet VIP E2:E column are in this format. I need to get them to read 20300008530300. As shown in the code below, I am extracting this data from Sheet1 column Z and pasting it in Sheet VIP column E2:E. Any help would be greatly appreciated. Thank you.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove hyphens and period and add number 2 to beginning of string

    Try and use the replace function
    I tried posting a reply but there seems to be a problem with the firewall and it's blocking my replies with code blocks
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Remove hyphens and period and add number 2 to beginning of string

    Here is a UDF that can be used like a formula in a cell
    =NumbersOnly(A1)

    Please Login or Register  to view this content.
    But can also be called from a procedure, like this
    Please Login or Register  to view this content.
    I have amended the values (removing non-numerics) after they arrived in VIP. You may prefer to do the job against column Z in sheet1
    - amend to match your requirements

    Or combining everything into one prodedure
    Please Login or Register  to view this content.


    EDIT
    - code modified as per comment in post#4
    Last edited by kev_; 04-12-2018 at 03:37 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Remove hyphens and period and add number 2 to beginning of string

    Oops I did not remember that 2 was to be added at the front of every number
    You could try
    Please Login or Register  to view this content.
    I will test tomorrow

    EDIT
    - tested & code modified
    Last edited by kev_; 04-12-2018 at 02:51 AM.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Remove hyphens and period and add number 2 to beginning of string

    Quote Originally Posted by mlski4751 View Post
    ...remove the hyphens and the period from 030-0008-5303.00. All numbers in the Sheet VIP E2:E column are in this format. I need to get them to read 20300008530300.
    Try
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-25-2013
    Location
    Delaware, OH
    MS-Off Ver
    Office 2019/Office 365
    Posts
    65

    Re: Remove hyphens and period and add number 2 to beginning of string

    Thank you so much Kev_, your last option combining everything worked wonderfully. You have been a great help.

  7. #7
    Registered User
    Join Date
    03-25-2013
    Location
    Delaware, OH
    MS-Off Ver
    Office 2019/Office 365
    Posts
    65

    Re: Remove hyphens and period and add number 2 to beginning of string

    Thank you for your efforts however it did not function properly. The post has been resolved, thank you again.

+ 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] Remove Spaces and Hyphens in a Tet String
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-05-2013, 06:02 PM
  2. Replies: 5
    Last Post: 12-22-2011, 11:29 PM
  3. Remove word(s) from string beginning with words from this array
    By agf12555 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2011, 12:28 PM
  4. Replies: 1
    Last Post: 04-06-2009, 06:06 PM
  5. Remove Hyphens from a number
    By smpayne69 in forum Excel General
    Replies: 7
    Last Post: 01-06-2007, 10:42 AM
  6. Is there away to add a zero to the beginning of number string?
    By Anthony in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-15-2006, 06:55 PM
  7. Replies: 4
    Last Post: 11-03-2005, 04:30 PM

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