+ Reply to Thread
Results 1 to 12 of 12

Concatenate - Macro way with checking of null cells

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Teplice
    MS-Off Ver
    2010
    Posts
    71

    Concatenate - Macro way with checking of null cells

    Hi,


    I have data in cells A, B, C, D and want to have results in E.

    The thing is, that i want to =CONCATENATE("text|";D2;"|";C2;"|";B2;"|";A2).

    If for example in C2 will be empty cell, i need this function not to give there two || separators, but just one.

    Idealy, please show me this function in cycle, which will go until empty cell Ax

    Thank you very much

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Concatenate - Macro way with checking of null cells

    Hi Odeen,

    Try this formula to do what you want.

    =SUBSTITUTE(CONCATENATE("text|",D2,"|",C2,"|",B2,"|",A2),"||","|")
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    Teplice
    MS-Off Ver
    2010
    Posts
    71

    Re: Concatenate - Macro way with checking of null cells

    Hmm,

    not functional. With this function, i can still see || besides if there are two blank columns besides.

    And the other thing is, that i would like this function to see made by macro. I have not to border myself everytime i want concatenate some things. In my work very common function.

    Thank you very much

  4. #4
    Registered User
    Join Date
    11-26-2012
    Location
    Kitchener, Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Concatenate - Macro way with checking of null cells

    Tri this
    Please Login or Register  to view this content.
    Last edited by aelgadi; 01-07-2013 at 12:41 PM.
    aelgadi

    > Click Star if I helped. Thanks

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Concatenate - Macro way with checking of null cells

    For two blanks together try this formula,

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(CONCATENATE("text|",D2,"|",C2,"|",B2,"|",A2),"||","|"),"||","|"),"||","|")

    If you need more then supply a sample workbook and let's see the real problem. Is it always columns D,C,B,A or is it the 4 columns to the left of the Concatenate formula?

  6. #6
    Registered User
    Join Date
    11-27-2012
    Location
    Teplice
    MS-Off Ver
    2010
    Posts
    71

    Re: Concatenate - Macro way with checking of null cells

    aelgadi

    -

    Hi, somehow after running this script of yours, nothing writes down in cells E at all column.

    What is wrong? I have Czech version of office, so i changed sheet to name of list, but nothing else were wrong in script (by debugger)

    Thanks for your assistance.

  7. #7
    Registered User
    Join Date
    11-27-2012
    Location
    Teplice
    MS-Off Ver
    2010
    Posts
    71

    Re: Concatenate - Macro way with checking of null cells

    MarvinP

    -

    SUBSTITUTE WORKS GREAT...
    and
    YES, it is always 4 columns to the left of E column. So your function is right.

    Thanks, new function i know...

    now just the macro way... it is for this time more important to me
    Last edited by Odeen; 01-07-2013 at 04:07 PM.

  8. #8
    Registered User
    Join Date
    11-26-2012
    Location
    Kitchener, Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Concatenate - Macro way with checking of null cells

    Is there any empty cell in Column A between Occupied cells or after the header?
    If the answer is "No", the only thing I can think of is the fact the macro is manupilating the wrong sheet
    so instead of sheet1 try to use Worksheets("Exactly type the name of sheet") as follows
    Please Login or Register  to view this content.
    Note: The sheet name appears on sheet tab
    Last edited by aelgadi; 01-07-2013 at 04:05 PM. Reason: Missing

  9. #9
    Registered User
    Join Date
    11-27-2012
    Location
    Teplice
    MS-Off Ver
    2010
    Posts
    71

    Re: Concatenate - Macro way with checking of null cells

    aelgadi

    -

    wow - this works great. So my mistake... but i have found one mistake.

    if i have columns like bellow, the script somehow did not find out, that there is new line, and concatenates also previous line.

    Please correct it for me. Anyway - thanks, you are great man

    A B C D E
    ab1 be1 ce1 de1 ab1|be1|ce1|de1
    ab1 be1 ab1|be1|ce1|de1|ab1|be1

  10. #10
    Registered User
    Join Date
    11-26-2012
    Location
    Kitchener, Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Concatenate - Macro way with checking of null cells

    If I'm understanding you correctly try the following
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Note: You need to run the macro again every time you introduce a new row

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Concatenate - Macro way with checking of null cells

    Ok Odeen,

    Here you go. This is much more than you wanted but attached is a Function that works like this. You can put in any range of cells in the FcnOdeen("range") and it will concatenate the cells from the last to the first and return what I think you want.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-27-2012
    Location
    Teplice
    MS-Off Ver
    2010
    Posts
    71

    Re: Concatenate - Macro way with checking of null cells

    aelgadi
    MarvinP

    wow, thanks both of you, the script is very good.

    Wish you all the good

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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