+ Reply to Thread
Results 1 to 8 of 8

Excel - combine rows with previous rows - conditionally

  1. #1
    Registered User
    Join Date
    05-21-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    73

    Excel - combine rows with previous rows - conditionally

    Hi,

    I have attached a workbook stating my requirement with expected result.
    Any help is greatly appreciated.

    Thanks.
    SB.
    Attached Files Attached Files
    Thanks
    Babu.S

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Excel - combine rows with previous rows - conditionally

    Try the below code

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Excel - combine rows with previous rows - conditionally

    Hi, :) Sixthsense :)

    me again - not your day of coding to my opninion.

    You define r but use i. What will happen if User Cancels the question about any of the ranges? Leave the user with a run time error and inside the VBE?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Excel - combine rows with previous rows - conditionally

    @ Holger,

    Yes you are right and lol

    First I thought to go for For Each approach and after that I thought to go for cell count approach but again forgot to change the r to i and the type of variable

    Then regarding your Input range Cancel question I always won't put much more effort while writing the code to cover A-Z because I wait for the OP to turnon on the suggested code and do the further developments based on the OP's reply.

    Yes seems to be not my day in coding the reason is I have more works and doing it by side by side and answering here too which may be the root cause for this distraction

  5. #5
    Registered User
    Join Date
    05-21-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Excel - combine rows with previous rows - conditionally

    Thanks Sixthsense,

    As per the code, user has to select the rows (child + parent) to combine them to one. i have n number of line items to combine, so is there a way that excel identifies the range of data (upto last updated row) and search row by row to combine child rows with parent rows leaving rows as it is which doesnt have child ?

    Additional info: parent row always begins with the numeric.

    Thanks
    SB.
    Last edited by sbabu16; 01-16-2014 at 03:18 AM.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Excel - combine rows with previous rows - conditionally

    That is how the suggested code was written

  7. #7
    Registered User
    Join Date
    05-21-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Excel - combine rows with previous rows - conditionally

    thanks a lot, it works.

    Thanks
    SB.

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Excel - combine rows with previous rows - conditionally

    Glad it helps you and thanks for the feedback and rep

+ 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. Combine Duplicate Rows and Combine Data in Rows
    By cherylmcgk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2013, 12:04 PM
  2. Excel 2010 Conditionally Hide Rows
    By akaempfe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-02-2012, 08:48 AM
  3. Merging rows of data and insertin rows conditionally
    By classixuk in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-28-2010, 07:02 PM
  4. Conditionally hide rows in Excel
    By dvlchd3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2008, 05:36 PM
  5. Replies: 5
    Last Post: 01-19-2005, 05:26 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