Add Cells to the right of a Text string

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Is it possible to add cells to the right of a text string to be included in a Conditional Format? I used the VBA below and it's great, but I like to extend it out, so cells will have the same fill color, and those borders to the right and top removed. Only cells to the right of the top row containing the "DATE: " Thank you.

VBA Code:
Sub DATE_BACKGROUND()
       
    Selection.FormatConditions.Add Type:=xlTextString, String:="DATE:", _
        TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).Borders(xlRight).LineStyle = xlNone
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 10027008
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
        
End Sub
TextString.JPG
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You have to use Formula instead of Text String. I would have to do some research on how to write it in VBA. Why are you using VBA for this rather than setting it up in the worksheet? What is Selection when this code is run, relative to the picture you have shown?
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,741
Members
449,050
Latest member
excelknuckles

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