Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
"Re-Merging" Cells
I currently have this code that someone helped me with. It is a spreadsheet
that has several merged cells on it to indicate a time block. In order to pick up a start and end date of the time block I start with a 1 and end with a 2. Then the code goes through and merges all cells in columns next to each other containing a 1. Can anyone tell me how to change the VB to include the 2 as well? Sub MergeCells() Dim RowCount As Variant Dim ColCount As Variant ' This macro looks for cells that contain "1" and merges them on the Caldendar sheet Range("B8").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Range("A8").Select Do Until ActiveCell = "" ActiveCell.Activate 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 Application.DisplayAlerts = False Range(Cells(RowCount, StartCol), _ Cells(RowCount, ColCount)). _ MergeCells = True Cells(RowCount, StartCol) = Data Application.DisplayAlerts = True End If ColCount = ColCount + 1 Loop ActiveCell.Offset(1, 0).Activate Loop Range("B8").Select Call Fill_In_Training_Blocks End Sub I am sure it is something really simple, I just don' t know how. Thanks Carrie -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200804/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Check if cells contain the word "Thailand", return "TRUE" | Excel Worksheet Functions | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
cells formatted to tick when text value "Y" if or null if "N" | Excel Discussion (Misc queries) |