Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Multiple IF's causing Run-time error 1004

I get the run-time error. I added a couple IF’s to the original formula. I believe the error is caused by multiple duplicate results (see the code below) like RTP and PNYP. If this is the case, how can I get the desired results? This is for code farther down the line to do CountIfs and SumIfs the result appears in a worksheet column.

With Sheet12 'Sheet12 = Raw Data - DS
        .Columns("C:D").Insert shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        .Range("G2:G" & .Cells(.Rows.count, "F").End(xlUp).Row).FormulaR1C1 = _
                       "=IF(RC[-1]=""Crossdock"",""CD"",IF(RC[-1]=""ReadyToPick"",""RTP"",IF(RC[-1]=""ReadyToPickUnconstrained"",""RTP"",IF(RC[-1]=""PickingPicked"",""PP"",IF(RC[-1]=""PickingPickedAtDestination"",""PP"",IF(RC[-1]=""PickingNotYetPickedPrioritized"",""PNYP"",IF(RC[-1]=""PickingNotYetPickedNotPrioritized"",""PNYP"",IF(RC[-1]=""Loaded"",""LD"","""")))))"
    End With

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Ideally this lookup would be on a list stored in a worksheet, but you can do it using an array directly in the formula:

=IFERROR(VLOOKUP(RC[-1],
    {"Crossdock","CD";
     "ReadyToPick","RTP";
     "ReadyToPickUnconstrained","RTP";
     "PickingPicked","PP"},
    2,FALSE),"")

(add the rest of your terms)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading