I get an error message ' Next Without For' at the bottom of the second loop, and I have no idea why:-

For L = LBound(BArr4) To UBound(BArr4) 'For every line
TmpArr4() = Split(BArr4(L), " ") 'Split into words

For M = LBound(TmpArr4) To UBound(TmpArr4)
Tmp4 = TmpArr4(M)
A_Is = Left(Tmp4, 1)

Select Case A_Is
Case "A": Ac_1 = R
Case "X": Xc_1 = R
Case "T": Tmp4 = Tc_R
End Select

TmpArr4(M) = Tmp4
Next M

BArr4(L) = Join(TmpArr4, " ") 'Join words back into lines

If T_Value = "" Then T_Value = 12
If Ac_1 + Xc_1 >= T_Value Then

BArr4(L - 1) = Replace(BArr4(L - 1), Ac_1 & Xc_1, Tc_R)

TmpArr5(L) = Split(BArr4(L), "A")
TmpArr5(0) = XBlah

BArr4(L) = XBlah & "A" & Ac_1 & Xc_1 & vbNewLine & "A" & Tc_R

Next L

I get the error message even when I comment out all the code between "Next M" and "Next L", Which I can't understand. Any ideas?