Tweak to code that checks colors of fonts and moves to proper shee

S

SCrowley

I have a code that Bernie Deitrick helped write for me. Now I need the pasted
text to reflect the orginal color. There can be several lines of text, all of
different colors, in the same cell.

Any guidance is greatly appreciated.

Sub UpdateWorksheets()

'Sheets(Array("Retail", "Community", "Workplace", "Corporate")).Select
'Sheets("Retail").Activate
'Application.Run "'2007 calendar.xls'!ClearCalendarSheets"


Dim i As Integer
Dim myCell As Range

Dim Erase1 As Boolean
Dim Erase2 As Boolean
Dim Erase3 As Boolean
Dim Erase4 As Boolean
Dim Erase5 As Boolean
Dim Erase6 As Boolean
Dim Erase7 As Boolean

For Each myCell In Worksheets("2007 Master
Events").Range("B5:H9,B14:H18,B23:H28,B33:H37,B42:H46,B51:H56,B61:H65,B70:H74,B79:H83,B88:H92,B97:H101,B106:H110")

Erase1 = True
Erase2 = True
Erase3 = True
Erase4 = True
Erase5 = True
Erase6 = True
Erase7 = True

For i = 1 To Len(myCell.Value)
If myCell.Characters(Start:=i, Length:=1).Font.ColorIndex = -4105 Then
If Erase1 = True Then
Worksheets("Corporate").Range(myCell.Address).ClearContents
Erase1 = False
End If
Worksheets("Corporate").Range(myCell.Address).Value = _
Worksheets("Corporate").Range(myCell.Address).Value &
Mid(myCell.Value, i, 1)
End If

If myCell.Characters(Start:=i, Length:=1).Font.ColorIndex = 3 Then
If Erase2 = True Then
Worksheets("Retail").Range(myCell.Address).ClearContents
Erase2 = False
End If
Worksheets("Retail").Range(myCell.Address).Value = _
Worksheets("Retail").Range(myCell.Address).Value & Mid(myCell.Value,
i, 1)
End If

If myCell.Characters(Start:=i, Length:=1).Font.ColorIndex = 11 Then
If Erase3 Then
Worksheets("Community").Range(myCell.Address).ClearContents
Erase3 = False
End If
Worksheets("Community").Range(myCell.Address).Value = _
Worksheets("Community").Range(myCell.Address).Value &
Mid(myCell.Value, i, 1)
End If

If myCell.Characters(Start:=i, Length:=1).Font.ColorIndex = 10 Then
If Erase4 Then
Worksheets("Workplace").Range(myCell.Address).ClearContents
Erase4 = False
End If
Worksheets("Workplace").Range(myCell.Address).Value = _
Worksheets("Workplace").Range(myCell.Address).Value &
Mid(myCell.Value, i, 1)
End If

If myCell.Characters(Start:=i, Length:=1).Font.FontStyle = "Bold" Then
If Erase5 Then
Worksheets("LA Bold").Range(myCell.Address).ClearContents
Erase5 = False
End If
Worksheets("LA Bold").Range(myCell.Address).Value = _
Worksheets("LA Bold").Range(myCell.Address).Value & Mid(myCell.Value,
i, 1)
End If

If myCell.Characters(Start:=i, Length:=1).Font.FontStyle = "Italic" Then
If Erase6 Then
Worksheets("Durham Italic").Range(myCell.Address).ClearContents
Erase6 = False
End If
Worksheets("Durham Italic").Range(myCell.Address).Value = _
Worksheets("Durham Italic").Range(myCell.Address).Value &
Mid(myCell.Value, i, 1)
End If

If myCell.Characters(Start:=i, Length:=1).Font.FontStyle = "Bold Italic"
Then
If Erase7 Then
Worksheets("DC Bold Italic").Range(myCell.Address).ClearContents
Erase7 = False
End If
Worksheets("DC Bold Italic").Range(myCell.Address).Value = _
Worksheets("DC Bold Italic").Range(myCell.Address).Value &
Mid(myCell.Value, i, 1)
End If

Next i
Next myCell
MsgBox "All sheets have been updated!"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top