0

I am running a macro that provides me a price but only if the name is 1 out of 9 provided names. I keep getting compile errors and I think its due to not having then statements after each or because it works if I only search for one name but when I do multiple it gets a compile error. Must be with the way I am listing these since it works with 1 name. I'm sure this isn't the fastest way but only way I could think of it.

If ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("IACFT2A")Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("IRPT3A") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("VERUS 2019-INV2") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("VERUS 2019-INV3") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("VERUS 2020-INV1") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("VERUS 2020-NPL1") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("IACFT1A") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("IOFIIIT1B") Or
        ThisWorkbook.Worksheets("Output").Cells(I, 4).Value = ("PBTT2A") Then

Perform Action
  • `Select Case` might be cleaner here: `Select Case ThisWorkbook.Worksheets("Output").Cells(I, 4).Value`, `Case "IACFT2A", "IRPT3A", ...`. – BigBen Apr 25 '23 at 20:05

0 Answers0