![]() |
merging cells using VB - Excel 2003
I have a row of 1's and 0's. I would like to merge all the cells with 1's
that are grouped in a row and not merge the 0's. Example: 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 So that the cells with 1's in them merge and the cells with 0's in them do not merge. Is is possible? Thanks in advance Carrie |
merging cells using VB - Excel 2003
Sub MergeCells() RowCount = ActiveCell.Row ColCount = 1 Do While Cells(RowCount, ColCount) < "" If Cells(RowCount, ColCount) = 1 Then StartCol = ColCount Data = 1 Do While Cells(RowCount, ColCount) = 1 And _ Cells(RowCount, (ColCount + 1)) = 1 ColCount = ColCount + 1 Data = Data & " 1" Loop Range(Cells(RowCount, StartCol), _ Cells(RowCount, ColCount)). _ MergeCells = True Cells(RowCount, StartCol) = Data End If ColCount = ColCount + 1 Loop "Carrie" wrote: I have a row of 1's and 0's. I would like to merge all the cells with 1's that are grouped in a row and not merge the 0's. Example: 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 So that the cells with 1's in them merge and the cells with 0's in them do not merge. Is is possible? Thanks in advance Carrie |
All times are GMT +1. The time now is 02:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com