B
Brian
I have a spreadsheet with 3 tabs, named "Red", "Green" and "Combined". The
data in columns A and B is the same on each tab, except that certain items
in column B of "Red" have text highlighted in Red, certain other items in
Column B of "Green" have text highlighted in green, while none of the text
in "Combined" is highlighted.
If an item in Column B of either "Red" or "Green" is highlighted, I want to
have the corresponding item of "Combined" highlighted in red. I was hoping
that the following macro would do it, but when I run it, it does not crash,
but it also appears to do nothing at all.
Can anyone help?
Sub MergeColors()
'
' MergeColors Macro
' Macro recorded 16/04/2004 by bclarke
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim WS3 As Worksheet
Dim Cell As Range
Set WS1 = Workbooks("£ account combined.xls").Sheets("Red")
Set WS2 = Workbooks("£ account combined.xls").Sheets("Green")
Set WS3 = Workbooks("£ account combined.xls").Sheets("Combined")
For Each Cell In WS1.Columns(2).SpecialCells(xlCellTypeConstants)
If Cell.Font.ColorIndex = 3 Then
WS3.Range(Cell.Address).Font.ColorIndex = 3
End If
Next
For Each Cell In WS2.Columns(2).SpecialCells(xlCellTypeConstants)
If Cell.Font.ColorIndex = 4 Then
WS3.Range(Cell.Address).Font.ColorIndex = 3
End If
Next
End Sub
data in columns A and B is the same on each tab, except that certain items
in column B of "Red" have text highlighted in Red, certain other items in
Column B of "Green" have text highlighted in green, while none of the text
in "Combined" is highlighted.
If an item in Column B of either "Red" or "Green" is highlighted, I want to
have the corresponding item of "Combined" highlighted in red. I was hoping
that the following macro would do it, but when I run it, it does not crash,
but it also appears to do nothing at all.
Can anyone help?
Sub MergeColors()
'
' MergeColors Macro
' Macro recorded 16/04/2004 by bclarke
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim WS3 As Worksheet
Dim Cell As Range
Set WS1 = Workbooks("£ account combined.xls").Sheets("Red")
Set WS2 = Workbooks("£ account combined.xls").Sheets("Green")
Set WS3 = Workbooks("£ account combined.xls").Sheets("Combined")
For Each Cell In WS1.Columns(2).SpecialCells(xlCellTypeConstants)
If Cell.Font.ColorIndex = 3 Then
WS3.Range(Cell.Address).Font.ColorIndex = 3
End If
Next
For Each Cell In WS2.Columns(2).SpecialCells(xlCellTypeConstants)
If Cell.Font.ColorIndex = 4 Then
WS3.Range(Cell.Address).Font.ColorIndex = 3
End If
Next
End Sub