Trying to create multi IF and Then VBA code to search for criteria and fill a cell with text.

JDSA84

New Member
Joined
Jul 14, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Production Log.jpeg

I'm trying to make a code that will look and see if columns meet certain criteria then Q= a value in text. Like below. But I need to do this in each cell from 2 to 500 and if Q2 = 4 then R2 = 5 S2 = 3 and T2 = 1 or 2


If [L2] = "" Or [L2] = "/" And CBool((Sgn([C2] - 1) + Sgn(30 - [C2])) > 0) And CBool((Sgn([E2] - 1) + Sgn(3556 - [E2])) > 0) Then [Q2].Value = "4"
The above code works but will be to much data for VBA with what I need it to do.

Criteria I'm following is
4 if L= Blank or /, C = 1 through 30, and E = 1 through 500 or C= 1 through 12 and E = 1 through 999
5 if M= Blank or /, C = 1 through 30, and E = 1 through 500 or C= 1 through 12 and E = 1 through 999
6 if L= Blank or /, C = 10 through 12, and E = 1000 through 5000
7 if L= Blank or /, C = 10 through 12, and E = 1000 through 8000
9 if L= Blank or /, C = 24 through 30, and E = 500 through 2000 or C = 31 through 36 and E = 1 though 500
13 if L= Blank or /, C = 31 through 36, and E = 500 through 2000 or C = 37 through 42 and E = 1 though 500
13 if M= Blank or /, C = 24 through 30, and E = 500 through 2000 or C = 31 through 38 and E = 1 though 500
14 if L= Blank or /, C = 38 through 52, and E = 1 through 2000 or C = 31 through 38 and E = 1 though 500
14 if M= Blank or /, C = 38 through 42, and E = 500 through 2000
15 if L= Blank or /, C = 52 through 180, and E = 1 through 8000
15 if M= Blank or /, C = 43 through 180, and E = 1 through 8000
3 if N= Blank or /, C = 1 through 20, and E = 1 through 8000 or C = 20 through 30 and E = 1 through 500
1 or 2 if O = Blank or /, C = 1 through 20, and E = 1 through 8000 or C = 20 through 24 and E = 1 through 500
12 if N = Blank or /, C = 20 through 24, and E = 500 through 8000 or C = 24 through 38 and E = 1 through 8000
12 if O = Blank or /, C = 20 through 24, and E = 500 through 8000 or C = 24 through 38 and E = 1 through 8000
15 if N = Blank or /, C = 38 through 180, and E = 1 through 8000
15 if O = Blank or /, C = 38 through 180, and E = 1 through 8000

I hope I explained this good enough as I know it's a lot of data to look at.
Any help will be greatly appreciated!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
SewingFloorProductionLog.xlsm
ABCDEFGHIJKLMNOPQRST
1PALLET NUMBERWORK ORDERDIA (in.)THICK (mm)LENGTH (ft.)SHIP BYALICOCIJOJISOSEXINS PRT ENDLine
304710218752894819.53667/7101010 - -1010
3147102487529354211717/710101010 -10 /
3247102587529454211897/71010 - -
334710268752954819.5997/7101010 - -
41231753187566724183177/7101010 - -10101010
4347053187435315121377/8101010 - -10 /
454705318743551291757/8101010 - -10 /
464707918750113013.54007/8101010 - -101010
474710018752632410.54067/8101010 - -101010 /
484710028752652416.52057/8101010 - -1010
4947100387526724121417/8101010 - -10
504710318753252410.58207/8101010 - -101010
514710718753452410.52207/8101010 - -
524710728753463013.52007/8101010 - -1010
5323167918753731810.511117/8101010 - -101010
5423167928753741810.512777/8101010 - -101010 /
5523167938753751810.59027/8101010 - -101010
56231685487538912627007/8101010 - -
572316855875390157.518007/8101010 - -10101010
JobSheet
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G:PCell Value=10textNO
J57:K133Other TypeColor scaleNO
G538:I538,L416:P453,G137:I144,L287:P318,M319:P369,H165:I165,L538:P538,G28:I28,H145:I146,G3:I24,L3:P24,L137:P144,G287:I453,L147:P161,L146:M146,O146:P146,L28:P28,G40:I133,M374:P415,M370:M373,O370:P373,G147:I161,G38:H39,L38:P133,L165:P281,G168:I281Other TypeColor scaleNO
J539:K541,J2:K24Other TypeColor scaleNO
J538:K538,J38:K56,J28:K28Other TypeColor scaleNO
J32:K34Other TypeColor scaleNO
L32:P34,G32:I34Other TypeColor scaleNO
J29:K31Other TypeColor scaleNO
L29:P31,G29:I31Other TypeColor scaleNO
 
Upvote 0
Think I've found the best way but can't get a loop to work. The loop would move it through the worksheet Looking for the values from Cell L2:L500, C2:C500, E2:E500 and place the Then in Q2:Q500 if there
Everything I've tried is bringing back a type mismatch.

VBA Code:
For r = 2 To 500
If Worksheets("JobSheet").Range("L" & r) = "" Or Worksheets("JobSheet").Range("L" & r) = "/" And Worksheets("JobSheet").Range("C" & r) <= 30 And Worksheets("JobSheet").Range("E" & r) <= 500 Then Worksheets("JobSheet").Range("Q" & r).Value = "4"
Next r
End
 
Upvote 0
Think I've found the best way but can't get a loop to work. The loop would move it through the worksheet Looking for the values from Cell L2:L500, C2:C500, E2:E500 and place the Then in Q2:Q500 if there
Everything I've tried is bringing back a type mismatch.

VBA Code:
For r = 2 To 500
If Worksheets("JobSheet").Range("L" & r) = "" Or Worksheets("JobSheet").Range("L" & r) = "/" And Worksheets("JobSheet").Range("C" & r) <= 30 And Worksheets("JobSheet").Range("E" & r) <= 500 Then Worksheets("JobSheet").Range("Q" & r).Value = "4"
Next r
End
Got this to work by removing formatting on the sheet. Now my issue is it put 4 in the cell if it meets one of the conditions not all.
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,182
Members
448,948
Latest member
spamiki

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