Determining range based on equal values in a column

  • Hello,


    First, I apologize if my formatting is off; I am not very accustomed to forum use. I am trying to automate a work process and have come to a road block where I need to dynamically create a range based on like values in column A. Basically, I have a large amount of data broken into subsets based on the value in A, and I am trying to find a way to iterate through the column, isolate like values (the column is already sorted), and then merge those rows within column A.


    [VBA]Application.DisplayAlerts = False
    mergeBottom = Cells(Cells.Rows.Count, "A").End(xlUp).Row
    For mergeRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row To 2 Step -1
    If Cells(mergeBottom, "A") <> Cells(mergeRow - 1, "A") Then Range(Cells(mergeRow, "A"), Cells(mergeBottom, "A")).Select
    Selection.Merge
    mergeBottom = mergeRow - 2
    Next mergeRow
    Application.DisplayAlerts = True
    [/VBA]


    The above is what I'm working with so far, and it compiles without error with the rest of my macro, but it doesn't seem to actually do anything. Any advice would be appreciated! I have read on several other advice sites that people tend to discourage merging; this isn't specifically what I'm actually trying to accomplish but is sufficient enough as an explanation to get me heading the right way.

  • Hello,


    Merged Cells should be totally banned ... !!! :pirate:


    Why don't you explain the real objective you have ...


    Most probably ... a solution in line with your final goal exists ...:wink:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • My intent is to determine a range within column A where like values exist, then use that range of rows to compare a list of dates in column D and determine which date is latest in any of four given fiscal years. I have my process nailed down for comparing the dates, but I can not figure out a consistent way to properly set my ranges. Some of my values are single occurrences, while some have 15-20. I hope that is helpful? If not, I can try to throw together a fake data set to represent the issue.


    Thanks for the reply.

  • Hello,


    Quote

    I can try to throw together a fake data set to represent the issue.


    Great idea ...!!!

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)