In message <#
[email protected]> of Sun, 20 Sep 2009
10:47:42 in microsoft.public.excel.programming, Bernie Deitrick
Ooops.... Hit send too soon!
.....you need to do that on a detail by detail basis.
Thanks to Joel <
[email protected]>, Bernie Deitrick
<
[email protected]>, Rick Rothstein <
[email protected]
erizon.net> for help. It took me a while to absorb the information.
(I had forgotten to mention I use Excel 2003.)
Joel's suggestion of POfInterest & .Cells(J, 2).copy _
destination:=POfInterest gave a syntax error. I am afraid I
could not figure what was intended.
Rick's suggestion of union frightened me as I had not used union before
and found a seemingly undocumented restriction that all arguments to
union must be on the same sheet.
So I took your work, Bernie, in creating this code which - ugly as it is
- does what I need. Somebody may propose some simplification
Private Sub ExpandQuestion()
Dim I As Long
Dim J As Long
Dim K As Long
Dim L As Long
Dim SheetName As String
Dim Scratch As Range
For I = 1 To 4
SheetName = "3." & I
If InStr(ActiveCell, SheetName) Then
With Workbooks("foo.xls").Sheets(SheetName)
Set Scratch = .Cells(1, 14)
Scratch.Value = ActiveCell.Value
For J = 3 To 12
If .Cells(J, 1) = 0 Then Scratch.Value = _
Scratch.Value & .Cells(J, 2).Value _
& .Cells(J, 14).Value
Next
K = Len(ActiveCell.Value)
For J = 3 To 12
If .Cells(J, 1) = 0 Then
For L = 1 To Len(.Cells(J, 2))
K = K + 1
Scratch.Characters(Start:=K, _
Length:=1).Font.Bold = _
.Cells(J, 2).Characters(Start:=L, _
Length:=1).Font.Bold
Next
For L = 1 To Len(.Cells(J, 14))
K = K + 1
Scratch.Characters(Start:=K, _
Length:=1).Font.Bold = _
.Cells(J, 14).Characters(Start:=L, _
Length:=1).Font.Bold
Next
End If
Next
Scratch.WrapText = ActiveCell.WrapText
Scratch.Copy ActiveCell
End With
Exit For
End If
Next
End Sub
Thanks, again, for all the help.