+ Reply to Thread
Results 1 to 10 of 10

Concatenate - help

  1. #1
    Registered User
    Join Date
    06-11-2005
    Posts
    10

    Concatenate - help

    Hi
    Here is what I am trying to do
    =CONCATENATE(I36:I39) I am trying to add the text in column I from 36 to 39. But when i use the above formula I am not getting the result.. I am just getting the first row back. I know we can concatenate using this =CONCATENATE(i36, i37, I38) BUT as i want to concatenate like 30 rows and very frequently i would like to have a way where i can just show the range of cells to be added. Appreciate any help and your time.
    Last edited by pralav; 06-21-2005 at 09:54 AM.

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    the formulae for range a1:a6 will be


    =a1 & a2 & a3 & a4 & a5 & a6

  3. #3
    Registered User
    Join Date
    06-11-2005
    Posts
    10
    Thank you for replying. I dont want to write the formula.. instead everytime i want to add bunch of cells in a row i just want to show the range so all the text will be concatenated into one cell. Please let me know if you have any idea abt it. Thank you.

  4. #4
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    You have to write the function for that.

    copy the below function in the module in vba editor,

    and use the function like

    in formula like =concat_range(a1:a20)




    Function concat_range(r As Range)

    Dim val As Variant
    Dim c As Range

    For Each c In r
    val = val & c.Value & " "
    Next
    concat_range = val
    End Function

  5. #5
    Registered User
    Join Date
    06-11-2005
    Posts
    10
    Thanks a lot anil,
    I am trying to use the formula.. i am newbie to excel vba.. I will play with it for some time now and get back to you on that.. just to make one this sure.. I can just use this formula and select the range everytime i wanna concateneate a bunch of cells right?.. Thanks a lot again

  6. #6
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    I can just use this formula and select the range everytime i wanna concateneate a bunch of cells right?

    Yes that is correct.


    Let me know if you have any questions

  7. #7
    Registered User
    Join Date
    06-11-2005
    Posts
    10
    Hey Anil
    That is great.. it works beautifully.. Only thing is could you tell me how I can add code to format it? I am adding a bunch of lines and I want them to be wrapped so they all the lines i added wont be

  8. #8
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    In what format do you want.

  9. #9
    Registered User
    Join Date
    06-11-2005
    Posts
    10
    Anil,
    I just want to make sure the when I add all that string they appear clearly in that one cell. I want all the text to appear in the cell and also I dont want them to be bunched into one line. As I am adding many lines from different cells I want them to appear line by line in the same cell. Please let me know. Thank you.

    pralav

  10. #10
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    Function concat_range(r As Range)

    Dim val As Variant
    Dim c As Range

    For Each c In r
    val = val & c.Value & Chr(10)

    Next

    concat_range = val


    End Function

+ 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