Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have multiple ranges in various locations in the worksheet where I need to
merge cells in each range. The ranges are seperate and independant of each other. Not merging into one big cell. Once the merge happens, a font is set up and text is placed in each of the cells. The problem is that all the ranges are merging, but the text is only placed in the first range. I assume the problem is in how the code is telling where to put the text. Here is the code: Sub Special_Terms_Booger() Dim MyRange As Range, MyRange1 As Range, MyRange2 As Range Set MyRange = Union(Range("M38:W42"), Range("M95:W99")) Set MyRange1 = Union(Range("M152:W156"), Range("M209:W213")) Set MyRange2 = Union(MyRange, MyRange1) MyRange2.Select With Selection .HorizontalAlignment = xlLeft .VerticalAlignment = xlCenter .WrapText = True .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True With ActiveCell.Characters(Start:=1, Length:=245).Font .Name = "Arial" .FontStyle = "Regular" .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With End With For Each cell In MyRange2 ActiveCell.FormulaR1C1 = _ "This is my text." Next cell End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
looping thru named ranges | Excel Programming | |||
Looping through ranges | Excel Programming | |||
looping through an array of ranges | Excel Programming | |||
Looping in VB with cell ranges | Excel Worksheet Functions | |||
Looping through named ranges | Excel Programming |