VBA code to perform conditional formatting

KWL

New Member
Joined
Apr 17, 2011
Messages
16
I am seeking help developing VBA code to perform the following conditional formatting:
I prepare a daily spreadsheet that varies in length (up to 3000 rows)…. Column A contains defined “groups” of various lengths beginning in A2 with a blank row separator between each group….Column Q (beginning in Q2) in my spreadsheet has numeric values that represent various ranks unique to the pre-defined groups, my goal is to add a corresponding bold (black) “border” in the adjacent cell (Column R) for all numeric values (ranks) shown in Column Q >0 and <6. (Note: Column R has blank cells that are used for manual entry at a later time…. The bold (black) “border” is intended to draw attention to facilitate the manual entry.)
Thanks in advance for any available help,
KWL
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Code:
Sub test()
 
Dim [B][I]theRange[/I][/B] As Range
 
Set [B][I]theRange[/I][/B] = Application.Intersect(Range("Q1:Q" & Rows.Count), _
                ThisWorkbook.Sheets("Sheet1").UsedRange)
 
[COLOR=blue]For Each Cell In[/COLOR] [B][I]theRange[/I][/B]
 
 [COLOR=green]   If Cell < 6 And Cell > 0 Then[/COLOR]
 
[COLOR=darkred]        With Cell.Offset(0, 1).Borders[/COLOR]
[COLOR=darkred]             .LineStyle = xlContinuous[/COLOR]
[COLOR=darkred]            .Weight = xlThick[/COLOR]
[COLOR=darkred]         End With[/COLOR]
[COLOR=pink] [/COLOR]
[COLOR=green]    End If[/COLOR]
 
[COLOR=blue]Next[/COLOR]
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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
Back
Top