# Conditional test not evaluating properly

#### Dr. Demento

##### Well-known Member
For the life of me, I cannot figure this out. When the cell at .Cells(i, col) has the value 0\1 (as text), my conditional statement that evaluates if str = "0/1" is FALSE. Likewise, str Like "0/*" is always FALSE for values like "0\9". What am I doing wrong?

Code:
``````' ~~ Format START/STOP cells for better visualization
col = tbl_Watchstop.ListColumns("Split counter").DataBodyRange.column
For i = 1 To tbl_Watchstop.ListRows.count + 1
str = .Cells(i, col).value
If str = "0/1" Then .Cells(i, col).Interior.Color = 6750156  ' ~~ Light green for START
If str Like "0/*" And str <> "0/1" Then .Cells(i, col).Interior.Color = 16764159  ' ~~ Light pink for STOP
Next i``````

### Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

#### BarryL

##### Well-known Member
what does str give you in the immediate window

Code:
``````' ~~ Format START/STOP cells for better visualization
col = tbl_Watchstop.ListColumns("Split counter").DataBodyRange.column
For i = 1 To tbl_Watchstop.ListRows.count + 1
str = .Cells(i, col).value
Debug.Print str
If str = "0/1" Then .Cells(i, col).Interior.Color = 6750156  ' ~~ Light green for START
If str Like "0/*" And str <> "0/1" Then .Cells(i, col).Interior.Color = 16764159  ' ~~ Light pink for STOP
Next I``````

#### Dr. Demento

##### Well-known Member
Code:
``````?str
0\1``````

#### Dr. Demento

##### Well-known Member
Oh, and ValType(str) is 8 (string)

bump

#### Tetra201

##### MrExcel MVP
For the life of me, I cannot figure this out. When the cell at .Cells(i, col) has the value 0\1 (as text), my conditional statement that evaluates if str = "0/1" is FALSE. Likewise, str Like "0/*" is always FALSE for values like "0\9". What am I doing wrong?
Comparing backslashes ("\") with forwardslashes ("/")?

Last edited:

#### Dr. Demento

##### Well-known Member
You've got to be kidding me!! I knew it had to be something bone-headed, but I had no idea I was THAT bone-headed!!!

Pointing out errors without being judgemental -- that's a community worth being a part of. Thanks, Tetra.

You are welcome.

Replies
8
Views
579
Replies
1
Views
414
Replies
5
Views
442
Replies
10
Views
2K
Replies
9
Views
242

1,191,219
Messages
5,985,330
Members
439,958
Latest member
qb0000

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

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