IF value resides in range

Ananthak275

Board Regular
Joined
Aug 22, 2020
Messages
128
Office Version
  1. 2013
Platform
  1. Windows
  2. MacOS
I'm having trouble creating a macro that accomplishes the following things:
1. If any value within the string has "progress" then the status should be set to 1 and end the loop.
2. If all the values in the range are either "done" or NULL or EMPTY then the status should set to 0 and end the loop.
3. If all the values in the range are either "starting" then the status should set to 2 and end the loop.

How do I differentiate between the two (check if the values are either all "done" or "starting" or any if the values have "progress" in it?
PC_Question = "A"
StartRow = 2
TC = "B"
endrow = "19"

Rng = Range(PC_Question & StartRow & ":" & TC & endrow).Value

For Each cel In Rng
if (instr(1.cel.value, "done" or NULL OR EMPTY) then
Status=0
if (instr(1.cel.value, "starting") then
Status=1
if (instr(1.cel.value, "progress") then
Status=2
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
For Each cel In Rng
if instr(1,cel.value, "done") or isNULL(cel.value) OR isEMPTY(cel.value) then
Status=0
Elseif instr(1,cel.value, "starting") then
Status=1
Elseif instr(1,cel.value, "progress") then
Status=2
End if
Next cel
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,003
Members
449,203
Latest member
Daymo66

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