+ Reply to Thread
Results 1 to 3 of 3

Manipulating strings in two columns

  1. #1
    Registered User
    Join Date
    03-05-2007
    Posts
    1

    Manipulating strings in two columns

    Hi I have column A which has the following format "--string1"... and column b which has the format "string2".. what I need is a function that will replace the "string2" in column b with "--string2" to match the number of dashes in column A. This varies from 1 to 3 dashes and I want to add those same # of dashes to column B (without destroying the existing data)

    Any help would be appreciated

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Talking

    Hi there,

    Say the data starts in cell A1, enter the following formula =REPT("-",SUM(LEN(A1)-LEN(SUBSTITUTE(A1,"-","")))/LEN("-"))&B1 into cell C1, copy it down as many rows as required, convert the formulas (or Column C) to values and delete Column B.

    Kind regards,

    Robert

    HTH

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695
    You won't be able to do a direct replacement without some code. Along the same lines as Robert I'd use this formula in C1 copied down

    =LEFT(A1,FIND(LEFT(TRIM(SUBSTITUTE(A1,"-"," "))),A1)-1)&B1

    If you want this in column B just copy column C, Edit > Paste Special > Values, to convert the formulas to values, then delete column B

+ 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