VBA: Set range within If Statement

FunsizedNerd

New Member
Joined
Mar 20, 2019
Messages
17
Looking to apply conditional formatting to a row of cells (Active Cell -->) IF the value of the active cell is a certain value. This is what I have so far
Code:
For Each c In range1
    If c.Value = "MB" Then
    Set rg1 = range(c, range(c).End(xlToRight))
    With rg1
        .Font.Color = RGB(0, 153, 0)
    End With
Next

I want it to search a range (range1) by each cell (c) to see if the cell has a certain value. If it does, then I want to select the range from this cell to the right, and then apply conditional formatting to this row of cells (Note: isn't from column A, it's from column I -->)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this.
Code:
For Each c In range1
    If c.Value = "MB" Then
    Set rg1 = range(c, c.End(xlToRight))
    With rg1
        .Font.Color = RGB(0, 153, 0)
    End With
Next
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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