Next without For

Hi

I am trying to create a VBA to clear a list with specific works.

I am having this issue:

Next without For.

Anybody could help me.

Thanks

Sub Macro1()

'

' Macro1 Macro

'

'

Dim a As Integer

'keyword.

Sheets("List Material to Deleted").Select

For a = 1 To 100

Text = Cells(a, 1)

If Text = "" Then Exit Sub

Cells(a, 2).FormulaR1C1 = "=LEN(RC[-1])"

LONGITUD = Cells(a, 2).FormulaR1C1 = "=LEN(RC[-1])"

'search to delete.

Sheets("ML").Select

Dim b As Integer

For b = 1 To 300

text2 = Cells(b, 1)

If text2 = "" Then Exit Sub Else

If (Left(Cells(b, 1), LONGITUD) = Text) Then

Cells(b, 1).ClearContents

Next b

End If

Sheets("List Material to Deleted").Select

Next a

End Sub

Bonjour,

Tu as simplement inversé l'ordre du "End If" et du "Next".

   For b = 1 To 300
      text2 = Cells(b, 1)
      If text2 = "" Then Exit Sub Else
      If (Left(Cells(b, 1), LONGITUD) = Text) Then
         Cells(b, 1).ClearContents
      End If      ' << ici
   Next b      ' << et ici

ric

Merci!

Rechercher des sujets similaires à "next without"