View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Merging cells and formats

For clarity, to resist my 'force-of-habit' the entire procedure need
not have events disable as Claus's 3rd post holds true...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Target.Column = Columns("D").Column Then Exit Sub

Dim vSrc, n&, lChr&, rngSrc As Range
Const lOffset& = -3: Const lResize& = 3
Set rngSrc = Target.Offset(0, lOffset).Resize(1, lResize)
vSrc = rngSrc: lChr = 1

Application.EnableEvents = False '//required to obviate recursion
Target.Value = Target.Value '//required to format characters
Application.EnableEvents = True

For n = LBound(vSrc, 2) To UBound(vSrc, 2)
With Target.Characters(lChr, Len(vSrc(1, n)))
.Font.Size = rngSrc.Cells(n).Font.Size
.Font.Bold = rngSrc.Cells(n).Font.Bold
.Font.Color = rngSrc.Cells(n).Font.Color
End With
'Increment to next start position
lChr = lChr + Len(vSrc(1, n))
Next 'n
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com