Condiional Formating Macro

absamant

New Member
Joined
Oct 17, 2006
Messages
11
have a macro which i got from this forum . It goegoes as follows

Sub Test()

For I = 1 To Sheets.Count
Sheets(I).Select
Dim Sh As Worksheet
Dim LastCol As Integer
Dim Lastrow As Integer
Set Sh = ActiveSheet
With Sh
LastCol = .Cells(14, .Columns.Count).End(xlToLeft).Column
Lastrow = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range(.Cells(14, LastCol + 1), .Cells(Lastrow, LastCol + 3)).FormulaR1C1 = "=RC[-3]-RC[-4]" .Cells(1, LastCol + 1).EntireColumn.Insert

End With
Next I
End Sub


Is there a way in which i can apply conditional formatng to the the range marked in bold. I require to mark any values not between -4 and 4 in bold red
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

northwolves

Well-known Member
Joined
Jun 21, 2006
Messages
1,122
Do a loop like the following codes:

Code:
Sub Macro1()
Application.ScreenUpdating = False
Dim sh As Worksheet, c As Range
For Each sh In Sheets
For Each c In sh.UsedRange
If Abs(c.Value) > 4 Then
c.Font.Bold = True
c.Font.Color = vbRed
End If
Next
Next
Application.ScreenUpdating = True
End Sub

Best Regards
 

absamant

New Member
Joined
Oct 17, 2006
Messages
11
ran the co, however gave me a run time error 13. Is there a way the code can pick up the range directly from the code i have pasted earlier. Since the range changes in every sheet it is essential that the macro detects the range and then does the conditional format
 

Forum statistics

Threads
1,136,616
Messages
5,676,835
Members
419,653
Latest member
analyticalchemist94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top