subscript out of range

I am getting an error when running the script

Do While (Not (Workbooks(bookmonth).Worksheets("by associate").Cells(4, i) = "dsl") Or Not (Workbooks(bookmonth).Worksheets("by associate").Cells(4, i) = "hsi"))

I am uncertain why this is coming up. i is currently set to 1, so it should be starting to search in cell a1.




Answer this question

subscript out of range

  • Asem Masri

    Is the type mismatch on that same line of code


  • joeydj

    thank you, there was an error in my code and it was not populating bookmonth correctly, however, I am now getting a type mismatch. How do I correct for this

  • Tarh ik

    I can not see anything wrong with the code that would produce a type mismatch on that line.

    Any value contained in the cell A4 would be compared to the two string values and would either proceed into the loop or pass over it.

    What value do you have in the cell when the test raises the error


  • Dave987654321

    yes. and it is plain text in the field i am pulling from

  • RileyEsco

    Hi,

    If i is currently 1 then are the other indexes correct

    What's in the variable bookmonth
    Is the sheetname really "by associate". Perhaps there is a extra space somewhere.




  • subscript out of range