I have created many sheets (around 30) in a same workbook. I'm trying to program with VBA where a value will appear in the designated cell of the multiples all at one, but there is an issue "Run time error 9, Subscript out of range".
Sub Invoice()
For i = 5 To 11
With Sheets("Sheet" & i)
.Range("J2") = "a"
End With
Next i
End Sub
As shown in the code, value "a" has to appear in cell J2 on every sheet from sheet5 to sheet11. Apparently, there is something, but I just don't know what has gone wrong?
Below, I tried testing with just 3 sheets and still it gives the same error. As you can see in the picture that the name of each sheet is spelled correctly? I tried rewriting the names, but it doesnt work as well...