+ Reply to Thread
Results 1 to 5 of 5

Insert column with text parts from two cells

  1. #1
    Forum Contributor
    Join Date
    05-24-2020
    Location
    London
    MS-Off Ver
    Office 365 pro
    Posts
    177

    Insert column with text parts from two cells

    Hello, everyone,
    I would like to insert a help column to the right of column A.

    Fox.png

    This column should take over the cell contents of A and also the contents of column C, unless it is a pure number.
    A number that is combined with text or characters does not count and can be used (row 4)

    There should be a hyphen between the text from A and the text from B.

    In the attached picture you can see the compound inserted column B.
    If column C is empty, then the macro should go to the next (D) and take the word or word/character combination and insert it after the hyphen (example row 12).
    If column D is also empty, then the macro should find the next described column and if there it takes the word or word-character combination, and so on. (row 20)

    If the column C or the next described column contains a pure number and no letter, then nothing should happen (row 19).

    I have a formula that can do this but I would like a code.

    =TEXTJOIN("-",TRUE,A1,IFERROR(INDEX(C1:K1,MATCH(1,ISTEXT(C1:K1)*(C1:K1<>""),0)),""))
    Thanks very much in advance for your help
    Attached Files Attached Files

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Insert column with text parts from two cells

    This should do the trick...
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-24-2020
    Location
    London
    MS-Off Ver
    Office 365 pro
    Posts
    177

    Re: Insert column with text parts from two cells

    Thank you very much and sorry for the late reply.

    It works fine.
    There is still one small flaw.
    It adds pure numers.

    Row 19 is

    Price Willing to Pay-2500

    And not

    Price Willing to Pay.

    Whenever there is only a number in cell C it should jump to the next. When there are no texts oder combined text and numbers it sould not add anything at all.


    If the row 19 for example is altered in the way the image shows.
    The script produces:
    Price Willing to Pay-2500
    like in the picture and not

    Price Willing to Pay-sef007

    The next non pure number cell is filled with
    sef007

    Thank you very much for the help so far.
    Attached Images Attached Images
    Last edited by CoSinus; 05-27-2020 at 07:58 AM.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Insert column with text parts from two cells

    It looks like your "pure numbers" are left-aligned, which tells me they are not "pure numbers", but instead are "numbers stored as text". If you change those to "pure numbers" the code should work fine. Alternatively, you can adjust the code to try coercing the cell values to numbers (e.g. add 0 or multiply by 1) and if the result is numeric proceed accordingly.

    When I download a copy of your workbook, put my code into it and run it, the 2,500 value does NOT get appended in row 19. If it does in your copy, that needs to be addressed.

  5. #5
    Forum Contributor
    Join Date
    05-24-2020
    Location
    London
    MS-Off Ver
    Office 365 pro
    Posts
    177

    Re: Insert column with text parts from two cells

    It works like a charm.
    I went with the second option.

    Thank you very much.
    You are great

+ 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. Insert text in whole calendar column (day) using Information from other cells
    By joelmoor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2019, 11:12 AM
  2. Insert spaces into specific parts of text string
    By southpaw5271 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-12-2016, 11:13 AM
  3. VBA to insert and merge cells until all text in column is visible
    By teaker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2016, 02:13 PM
  4. Insert Rows in between cells of text in different column
    By king10001 in forum Excel General
    Replies: 2
    Last Post: 05-26-2015, 11:46 AM
  5. Replies: 0
    Last Post: 02-09-2011, 07:13 PM
  6. How do I insert cells at certain parts of rows
    By tweacle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2007, 03:06 PM
  7. How do I strip out some parts of a column of text data?
    By footballcmr2 in forum Excel General
    Replies: 3
    Last Post: 07-01-2005, 03:05 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