+ Reply to Thread
Results 1 to 12 of 12

How to identify the first and last cells of a range of cells with the same value & merge?

  1. #1
    Forum Contributor
    Join Date
    11-01-2018
    Location
    England
    MS-Off Ver
    2016
    Posts
    280

    How to identify the first and last cells of a range of cells with the same value & merge?

    I am currently developing an application using C# involving Excel. It's difficult to create logic within C# to get a desired Excel output.

    So I have an idea to insert VBA code into Excel via C#.

    I am no expert in VBA - I am needing help to achieve the following output:

    Situation

    I am aiming to merge the values like so:

    1.jpg

    Desired output

    And here is my desired output:

    2.jpg

    Using VBA, how can I achieve such target.

    My attempt

    Please Login or Register  to view this content.
    I gave it an attempt from some research.. this is working.. but I couldn't find anything to merge to the A4 page break.
    Attached Files Attached Files

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    You are interesting in which row PageBreaks are.
    use:
    Please Login or Register  to view this content.
    to find out row for X pagebreak.
    Then in loop
    Please Login or Register  to view this content.
    do merge.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Please try

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    11-01-2018
    Location
    England
    MS-Off Ver
    2016
    Posts
    280

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Thank you for that.. How would I change this to E & D columns I changed it to this.. but nothing is happening.


    Please Login or Register  to view this content.

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Maybe try

    Please Login or Register  to view this content.
    If this doesn't work, please provide sample file.

  6. #6
    Forum Contributor
    Join Date
    11-01-2018
    Location
    England
    MS-Off Ver
    2016
    Posts
    280

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Hi,

    Shows a subscript out of range error.

    But - If I clear out the values in the A column.. it works as expected...

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Try

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-01-2018
    Location
    England
    MS-Off Ver
    2016
    Posts
    280

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    See the print preview for the attached workbook.

    Untitled.jpg

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Something weird with Footer.

    try this

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-01-2018
    Location
    England
    MS-Off Ver
    2016
    Posts
    280

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    That is perfect, just what I was after. Appreciate your help.

  11. #11
    Forum Contributor
    Join Date
    11-01-2018
    Location
    England
    MS-Off Ver
    2016
    Posts
    280

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Sorry to bother.. getting a subscript out of range for this one.

  12. #12
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: How to identify the first and last cells of a range of cells with the same value & mer

    Last try

    Please Login or Register  to view this content.

+ 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. Replies: 3
    Last Post: 09-09-2019, 03:59 PM
  2. [SOLVED] Identify first cell of each range of coloured cells - adapting a calendar to display name
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2019, 03:49 AM
  3. [SOLVED] Identify the highest value over a range of cells and classify the result
    By MTC2016 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-08-2017, 01:24 PM
  4. Search for value in column A, then identify rows from range of nearby cells, then copy
    By hadamhiram in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2015, 09:46 AM
  5. [SOLVED] Select variable range; identify & delete rows with blank cells
    By alter54 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-28-2013, 04:40 PM
  6. Identify & highlight if all cells in a fixed range are blank
    By heena.singh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-24-2013, 05:57 AM
  7. Identify a range of cells containing dates
    By RJSohn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-09-2006, 07:48 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