Option Explicit
Public Sub ApplyBRIO()
Dim wksFrom As Worksheet
Dim wksTo As Worksheet
Dim rngFrom As Range
Dim rngTo As Range
Dim c As Range
Dim lngColArea As Long
Set wksFrom = Worksheets("BRIO Paths x JIL")
Set wksTo = Worksheets("Path Constraints ex JIL")
Application.ScreenUpdating = False
For Each c In wksFrom.Range("B1:O1")
If c.NumberFormat Like "ddd *" Then
If rngFrom Is Nothing Then
Set rngFrom = wksFrom.Range(c.Cells(3, 1), wksFrom.Cells(62, c.Column))
Else
Set rngFrom = Union(rngFrom, wksFrom.Range(c.Cells(3, 1), wksFrom.Cells(62, c.Column)))
End If
End If
Next
Set rngTo = wksTo.Range("B3:H62")
For lngColArea = 1 To rngFrom.Areas.Count
For Each c In rngFrom.Areas(lngColArea).Cells
If Len(Trim(c.Value)) <> 0 Then
Select Case rngTo.Cells(c.Row - 2, lngColArea).Interior.Color
Case vbYellow, vbRed
'just transfer the text
rngTo.Cells(c.Row - 2, lngColArea).Value = c.Value
Case Else
'transfer both text and interior color
rngTo.Cells(c.Row - 2, lngColArea).Value = c.Value
rngTo.Cells(c.Row - 2, lngColArea).Interior.Color = c.Interior.Color
rngTo.Cells(c.Row - 2, lngColArea).Font.Color = c.Font.Color
End Select
'Stop
End If
Next
Next
Application.ScreenUpdating = True
End Sub
|