Formulas and Formats

  • Thread starter Thread starter J Donahue
  • Start date Start date
J

J Donahue

Is there any way to have a formula pull in the format of
another cell as well as the content of the cell?

For example in Cell A1 I have a formula

IF (B1>0,B1,C1)

Suppose that B1 is formatted so the cell is highlighted
in yellow and C1 is formatted so the cell is highlighted
in blue. Is there any way that I can make it so that
when cell A1 pulls in either B1 or C1 amounts it pulls in
the highlights as well?
 
-----Original Message-----
Is there any way to have a formula pull in the format of
another cell as well as the content of the cell?

For example in Cell A1 I have a formula

IF (B1>0,B1,C1)

Suppose that B1 is formatted so the cell is highlighted
in yellow and C1 is formatted so the cell is highlighted
in blue. Is there any way that I can make it so that
when cell A1 pulls in either B1 or C1 amounts it pulls in
the highlights as well?
.
Use Format --> Conditional Formatting

Condition 1 = If Value = B1
Condition 2 = If Value = C1
 
There's real no easy way. What you can do is set up a
worksheet_change macro to copy over the formats:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Intersect(Range("B1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Range("B1").Value > 0 Then
Range("B1").Copy
Range("A1").PasteSpecial Paste:=xlFormats
Else
Range("C1").Copy
Range("A1").PasteSpecial Paste:=xlFormats
End If
Application.CutCopyMode = False
Application.EnableEvents = True
End Sub

Be aware that a change in formatting for B1 or C1 will not
trigger the code.

Right-click on the tab, View Code, and paste it into the
window.

HTH
Jason
Atlanta, GA
 
Back
Top