Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop help
Hi All,
Can you help me turn this into a loop/iteration macro? The macro takes the value in AA2 and AB2 and concatenates them (with a charater return) while preserving rich text formatting from the source cells and places the result into AC2. I need this macro to then do this down the rest of my results (preferably just as far down as their are results in Column G). Any help would be greatly appreciated. Sub PreserveRichText() Dim SourceCells As Range Dim DestRange As Range Dim Cell As Range Dim SourceChar As Long Dim DestChar As Long Dim SourceFont As Font Const DELIM As String = vbCr Set SourceCells = Range("AA2:AB2") Set DestRange = Range("AC2") DestRange.ClearContents 'Build the string first For Each Cell In SourceCells DestRange.Value = DestRange.Value & DELIM & Cell.Value Next DestRange.Value = Mid(DestRange.Value, Len(DELIM) + 1) 'Now process each Char For Each Cell In SourceCells For SourceChar = 1 To Cell.Characters.Count Set SourceFont = Cell.Characters(SourceChar, 1).Font DestChar = DestChar + 1 With DestRange.Characters(DestChar, 1).Font .Bold = SourceFont.Bold .ColorIndex = SourceFont.ColorIndex .FontStyle = SourceFont.FontStyle .Name = SourceFont.Name .Size = SourceFont.Size .Underline = SourceFont.Underline ' Other properties ? End With Next DestChar = DestChar + Len(DELIM) Next End Sub Thanks very much, -David |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
(Complex) Loop within loop to create worksheets | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |