Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2015, 09:40 PM
Snaybot Snaybot is offline VBA merging cells and counting Merged rows Windows 7 64bit VBA merging cells and counting Merged rows Office 2013
Novice
VBA merging cells and counting Merged rows
 
Join Date: Sep 2015
Posts: 22
Snaybot is on a distinguished road
Default VBA merging cells and counting Merged rows

I have a series of varying merged cells only in column A, such as a merged cell of 8 rows and then next merge cells is 4 cells and the next is 7 cells and so on and so on...


I Would like to figure out How to create a macro that instead of the 8 row merged cell it goes to 7 cells

So I would like the existing merged cells row count to go down by 1



so for 8 row merged cell it would go to a 7 row merged cell

so for 5 row merged cell it would go to a 4 row merged cell

so for 20 row merged cell it would go to a 19 row merged cell
Reply With Quote
  #2  
Old 11-09-2015, 03:02 AM
Debaser's Avatar
Debaser Debaser is offline VBA merging cells and counting Merged rows Windows 7 64bit VBA merging cells and counting Merged rows Office 2010 32bit
Competent Performer
 
Join Date: Oct 2015
Location: UK
Posts: 221
Debaser will become famous soon enough
Default

You could do this:

Code:
Sub resizeMerge()

    Dim lRow                  As Long
    Dim lCount                As Long
    Dim lLastRow              As Long

    lRow = 1

    ' change to your last row
    lLastRow = 25

    Do While lRow <= lLastRow
        With Cells(lRow, "A")
            If .MergeCells Then
                lCount = .MergeArea.Cells.Count
                .UnMerge
                If lCount > 2 Then .Resize(lCount - 1).Merge
            End If
        End With
        lRow = lRow + lCount
    Loop
End Sub
Reply With Quote
  #3  
Old 11-09-2015, 03:56 AM
Snaybot Snaybot is offline VBA merging cells and counting Merged rows Windows 7 64bit VBA merging cells and counting Merged rows Office 2013
Novice
VBA merging cells and counting Merged rows
 
Join Date: Sep 2015
Posts: 22
Snaybot is on a distinguished road
Default

Thank you!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA merging cells and counting Merged rows counting cells to the right of criteria Taras49 Excel 5 11-05-2015 11:52 AM
VBA merging cells and counting Merged rows Table will not allow sorting because "cells are merged". I can't find the merged cells. wendyloooo Word Tables 1 05-26-2015 01:19 PM
VBA merging cells and counting Merged rows Merging Rows - HELP please! MessyJessy Excel 7 01-14-2015 01:38 AM
VBA merging cells and counting Merged rows Counting Color in Cells Alaska1 Excel 7 07-28-2013 04:36 PM
VBA merging cells and counting Merged rows merging rows and creating sub-rows gib65 Excel 2 12-09-2011 02:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft