# tidy betty

#### fry

##### Active Member
Hi again all

Code:
``````For r = 11 To 12
On Error Resume Next
w = WorksheetFunction.Search("boc", Cells(r, "B"))
x = WorksheetFunction.Search("a-plant", Cells(r, "B"))
y = WorksheetFunction.Search("a plant", Cells(r, "B"))
If w > 0 Then
ActiveSheet.Tab.ColorIndex = 5
End If
If x > 0 Then
ActiveSheet.Tab.ColorIndex = 10
End If
If y > 0 Then
ActiveSheet.Tab.ColorIndex = 10
End If
If z > 0 Then
ActiveSheet.Tab.ColorIndex = 10
End If
Next``````

Many Thanks

P.S. Sorry for the DOUBLE post above but my puter crashed mid submit!!

### Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

#### ravishankar

##### Well-known Member
Hi
try the following codes
Code:
``````Sub hhh()
For a = 1 To 4
b = Choose(a, "boc", "a-plant", "a plant", "adlington")
c = Choose(a, 5, 10, 10, 10)
If Cells(11, 2) = b Or Cells(12, 2) = b Then
ActiveSheet.tab.ColorIndex = c
End If
Next a
End Sub``````
Ravi

#### facethegod

##### Well-known Member
Code:
``````Option Base 1
Public Sub trythis()
On Error Resume Next
Dim arr() As Variant
Dim i As Integer
arr = Array("boc", "a-plant", "a plant", "adlington")
For i = 1 To 4
If Not IsError(Application.Search(arr(i), Cells(11, "B"))) Or Not IsError(Application.Search(arr(i), Cells(12, "B"))) Then
Select Case i
Case 1
ActiveSheet.Tab.ColorIndex = 5
Case Is > 1
ActiveSheet.Tab.ColorIndex = 10
End Select
End If
Next
End Sub``````

#### Norie

##### Well-known Member
This is a shot in the dark since I've no idea if there could be any other values in B11/12 that you need to deal with.
Code:
``````    If InStr(Range("B11"), "boc") <> 0 Or InStr(Range("B12"), "boc") <> 0 Then
ActiveSheet.Tab.ColorIndex = 5
End If

If Left(Range("B11"), 1) = "a" Or Left(Range("B12"), 1) = "a" Then
ActiveSheet.Tab.ColorIndex = 10
End If``````

Replies
12
Views
284
Replies
1
Views
196
Replies
2
Views
470
Replies
28
Views
1K
Replies
0
Views
154

1,181,416
Messages
5,929,790
Members
436,694
Latest member
dpatete

### 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.

### Which adblocker are you using?

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

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