+ Reply to Thread
Results 1 to 3 of 3

Text spacing with characters

  1. #1
    Registered User
    Join Date
    10-26-2016
    Location
    Australia
    MS-Off Ver
    excel 2016
    Posts
    46

    Text spacing with characters

    Im trying to work out how to add spaces and characters entered by a barcode scanner to make it easier to read.

    This is how it automatically inserts into a cell Z00126062021A10061101
    This is how I would like it to look Z001-26062021-A1-006-1101


    Sometimes the last set of values are 3 digits sometimes 4 see below.
    Z001-26062021-A1-006-1101
    Z001-26062021-A1-006-980


    Can I use a formula to achieve this or is the only way using VB?

    Thanks

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,971

    Re: Text spacing with characters

    Try this:

    =LEFT(A2,4)&"-"&MID(A2,5,8)&"-"&MID(A2,13,2)&"-"&MID(A2,15,3)&"-"&MID(A2,18,4)

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,424

    Re: Text spacing with characters

    Another way...

    =REPLACE( REPLACE( REPLACE( REPLACE(A1,18,0,"-"),15,0,"-"),13,0,"-"),5,0,"-")

    NOTE: You can remove the spaces between the REPLACE function calls if you want... they are there to stop this forum's comment processor from issuing an error message.
    Last edited by Rick Rothstein; 07-28-2021 at 08:56 PM.

+ 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. remove spacing behind the text
    By okl in forum Excel General
    Replies: 1
    Last Post: 01-12-2018, 05:20 AM
  2. Macro for adding text, spacing, and a replace in a text string.
    By scapegoat9595 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 10:44 AM
  3. Creating an index amongst different characters and spacing
    By LastShadow in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2012, 09:24 PM
  4. Question on spacing out characters
    By Alabaster_W in forum Excel General
    Replies: 3
    Last Post: 09-09-2011, 05:06 PM
  5. Text spacing in drop down lists
    By Cathy Landry in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  6. [SOLVED] Text spacing in drop down lists
    By Debra Dalgleish in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 09-06-2005, 06:05 AM
  7. [SOLVED] Text spacing in drop down lists
    By Debra Dalgleish in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 09-06-2005, 04:05 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