I have some text data I want to search through and highlight.
It is daily / monthly / annual tasks organized (and seperated as groups) by frequency... so I have a seperate box for the daily, weekly, etc.
There are 3 columns for each group... "Type", "Frequency" and "Description".
I have a Listbox that has all the Types of tasks in it, and when you select one and press on a button, it highlights all the tasks that correspond to that...
So far the only way I have been able to do this is through VBA conditional formatting.
But it only highlights the type of task and I haven't been able to figure out how to make it ALSO highlight the two columns next to it...
I was exploring how to do that with a search but could not implement it correctly.
here is my code
Private Sub CommandButton1_Click()
Dim typeSelection As String
Dim rng As Range
Set rng = Sheet4.Range("$E$3:$O$23")
typeSelection = ListBox1.Text
Debug.Print rng.Address
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlTextString, String:=typeSelection, _
TextOperator:=xlBeginsWith
.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
.FormatConditions(1).Font.Bold = True
'Debug.Print .FormatConditions(1).AppliesTo.Address
'.FormatConditions(1).ModifyAppliesToRange .FormatConditions(1).AppliesTo.Offset(RowOffSet:=0, ColumnOffset:=2)
'.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
'.FormatConditions(1).Font.Bold = True
'Debug.Print .FormatConditions(1).AppliesTo.Address
End With
Dim rCell As Range
Dim cRng As Range
For Each rCell In rng.Cells
Set cRng = rCell
Debug.Print rCell.Address
isConditionallyFormatted (rCell)
Next rCell
End Sub
I would suggesst something like this :
Here is the code :