#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 116
Default "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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if cells contain the word "Thailand", return "TRUE" ali Excel Worksheet Functions 7 September 14th 07 09:53 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
cells formatted to tick when text value "Y" if or null if "N" Jay Excel Discussion (Misc queries) 7 January 13th 06 09:16 AM


All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"