IF cell between values, then...

BravoBravoAu

Board Regular
Joined
Nov 8, 2011
Messages
64
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

Hopefully another quick and easy formatting (or conditional formatting) solution here, but I'm stuck.

I have a pretty sizable workbook, with one section focusing on hours worked for a particular task. What I'd like to be able to do is, depending on how many hours are recorded as being worked in column A, then an X is placed in the range (less than 2 hours / 2-3 hours / 3-6 hours / more than 6 hours).

I envisage cell B2 would need to be formulated IF A2 is less than 2 hours, then "X"; C2 IF A2 is 2-3, then "X"; D2 if A2 is 3-6, then "X"; E2 IF A2 is more than 6 then "X". BUT, I can't seem to get any to work as intended. Please help?

[TABLE="width: 469"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Hours worked[/TD]
[TD]0-2[/TD]
[TD]2-3[/TD]
[TD]3-6[/TD]
[TD]6+[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]X[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]5[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]X[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]9[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]X[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]2[/TD]
[TD] [/TD]
[TD]X[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]3[/TD]
[TD] [/TD]
[TD]X[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]6[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]7[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]5[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]4[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody><colgroup><col><col><col span="4"></colgroup>[/TABLE]
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I've solved it.

I put an additional column in to B to consider a nested IF formula (So...=IF(A2<2,"A",IF(A2<3,"B",IF(A2<6,"C","D")))).

C2 has the formula =IF(B2="A","X","").
D2 has the formula =IF(B2="B","X","").
E2 has the formula =IF(B2="C","X","").
F2 has the formula =IF(B2="D","X","").

I'm sure this isn't the best way, but it now works.

Thanks for your help.
 
Upvote 0
You can do this with a single formula, take the first formula below enter it in B2, drag across then down


Book1
ABCDE
1Hours worked0-22-33-66+
21X   
35X
49X
52X
63X
76X
87X
95X
104X
112X
Sheet2
Cell Formulas
RangeFormula
B2=IF(COLUMN(A1)=MATCH($A2, {0,2,3,6,99}), "X", "")
C2=IF(COLUMN(B1)=MATCH($A2, {0,2,3,6,99}), "X", "")
D2=IF(COLUMN(C1)=MATCH($A2, {0,2,3,6,99}), "X", "")
E2=IF(COLUMN(D1)=MATCH($A2, {0,2,3,6,99}), "X", "")
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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