+ Reply to Thread
Results 1 to 6 of 6

Complex Concetenate of cells using vba

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    Helsingborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    47

    Complex Concetenate of cells using vba

    Hello.

    Im not really sure how to explain this or if it even could be done, but iv searched the forums and web without any luck so here goes.
    To try to make it easier im posting an example WB of the result i want using the Concetenate formula.

    The excel wb is a generated file from a database of information, It is always named "Rapport.xls" when data is exported. this one has a (1) becouse its same one exported twice.

    What i would like to do is Concetenate all cells cointaining for example "Golv" in the header. as i have done in the workbook, then its just copy row and special paste values. in column to the left of the column with red marked header.

    Problem is that some cells in columns E to F has more than one line inside, so the quite allready long concetenate formula must be extended. to make it work for cells that have 2 lines so the information belonging to right line inside cells gets the right information. Now this is done quite easy, and with just expand rest of cells gets same formula. the more complex part comes with column AB for the "Övrigt" cells. Some have 1 line some have 2-3 and some have 8-11 lines in the cells.
    So i must edit formula for the longer ones and make it fit so it works for the 8-11 line cells.

    Click further down when u find a cell containing much info to se what i am talking about.

    Now could this be done by say maybe a smarter way using formulas or can there be some VBA code that handles this?

    The concetenate formula i must give credit to you guys for providing it to me on this forum. but i need something easier and better way, if it is possible.

    I know i may be asking alot, but i could really use some help here.

    By different line i mean that in the cells information is separated by (Alt + Enter) line break. and data from example Cell E2 line 1 must be matched wit data from cell F2-H2 line 1, and line 2 in cell E2 with data from line 2 in cell F2-H2 and so on.

    I hope i make at least some sense to someone who could help me. Otherwise just let me know and i will try to explain more. hoppfully the example wb provides better example. I have done all the modification of formula in all but the lower part of AB column. Data in the columns with red marked headers is how the result should look like.

    Thanks alot in advance for all the help you guys choose to provide!

    Cheers
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Complex Concetenate of cells using vba

    Hello lavinius,

    Please check your file. It down loads fine but when Excel attempts to open it, the following warning dialog appears...

    The file you are trying to open, 'Rapport(1).xls', is in a different format than specified by the file extension.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-09-2013
    Location
    Helsingborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Complex Concetenate of cells using vba

    Upploaded file with *.xlsx extension instead. should not be getting the pop upp warning when you try to open it now.

    Thanks for the heads up.

    Cheers
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Complex Concetenate of cells using vba

    Hello lavinius,

    Thanks for uploading the new file. It opens with no problems.
    Last edited by Leith Ross; 08-16-2013 at 01:53 PM.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Complex Concetenate of cells using vba

    Hello lavinius,

    The Concatenate function in Excel is pretty much useless so, I am going to ask you to explain what is happening. I haven't the time to decipher your formulas.

  6. #6
    Registered User
    Join Date
    01-09-2013
    Location
    Helsingborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Complex Concetenate of cells using vba

    Ofcourse, just looking at the formula where it is a bit longer gives one a headache, so understandable.

    What is does is pretty much this,

    It maps information from 4 different colums into one for every row in the sheet. But some cells have more than one line of information in it, so it maps the information by line. hope that makes sense. So if in fist cell the data is devided in say 3 lines. it need to get line 1 and then line 1 from the rest of the colums and then line 2 and so on.

    Lines in the cells are divided by a (Alt + Enter) limiter. if i use just regular Concetenate, the function takes all the lines in first column, then adds the next column at the end and so on, making it hard to se what information belongs to what material for example.

    Does that explain it somehow?, and last but not least. the number of lines in cells vary. so cells in one row might only have 1 line, but row 2 has 4 line and so on.

    If you look in column D2, thats how the result should look like in text form not in formula code. and it maps info from cell E2, F2, G2, H2.

    Hope that explains something.

    Thanks for your time and patiance!!

    Cheers

+ 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. Only pick up cells with numbers in already complex formula
    By gcuddy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-28-2013, 12:25 AM
  2. Complex problem updating cells
    By Khamsouk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2012, 05:18 AM
  3. excel said it is too complex, cannot copy visible cells
    By reedzhou in forum Excel General
    Replies: 0
    Last Post: 07-08-2011, 12:01 AM
  4. Cannot copy cells because they are too complex
    By opg in forum Excel General
    Replies: 1
    Last Post: 01-05-2009, 04:18 PM
  5. [SOLVED] complex fomula: counting cells that are blank
    By shmurphing in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-06-2005, 06:06 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