SOLVED

cannot figure it out

Occasional Contributor

I always get an error next without for

 

 

Sub MAKEIMPORTLIST()
Dim count As Integer
Dim a As Integer
Dim rg As Range

'MsgBox Application.CountA(Range("A:A"))

count = Application.CountA(Range("A:A"))

Worksheets("prix kit").Activate
'MsgBox "range A" & a

Worksheets("Prix Kit").Range("a2:b68").Copy
Worksheets("liste de kit").Range("a2").PasteSpecial Paste:=xlPasteValues
Worksheets("Prix Kit").Range("l2:l68").Copy
Worksheets("liste de kit").Range("c2").PasteSpecial Paste:=xlPasteValues
'Worksheets("Prix Kit").Range("o2:o68").Copy
'Worksheets("liste de kit").Range("d2").PasteSpecial Paste:=xlPasteValues

Worksheets("liste de kit").Activate

For a = 2 To count

If Range("d" & a) = 0 Then

'MsgBox "zero"

Worksheets("Prix Kit").Range("m" & a).Copy
Worksheets("liste de kit").Range("d" & a).PasteSpecial Paste:=xlPasteValues

Else

If Worksheets("Prix Kit").Range("o" & a) < Worksheets("prix kit").Range("m" & a) Then

Worksheets("Prix Kit").Range("m" & a).Copy
Worksheets("liste de kit").Range("d" & a).PasteSpecial Paste:=xlPasteValues

Else

Worksheets("Prix Kit").Range("o" & a).Copy
Worksheets("liste de kit").Range("d" & a).PasteSpecial Paste:=xlPasteValues

End If

Next a

End Sub

2 Replies
best response confirmed by Slyfox6915 (Occasional Contributor)
Solution

@Slyfox6915 

It seems that in one of the IF THEN ELSE loops END IF is missing. I added this line in red fontcolor.

 

Sub MAKEIMPORTLIST()
Dim count As Integer
Dim a As Integer
Dim rg As Range

'MsgBox Application.CountA(Range("A:A"))

count = Application.CountA(Range("A:A"))

Worksheets("prix kit").Activate
'MsgBox "range A" & a

Worksheets("Prix Kit").Range("a2:b68").Copy
Worksheets("liste de kit").Range("a2").PasteSpecial Paste:=xlPasteValues
Worksheets("Prix Kit").Range("l2:l68").Copy
Worksheets("liste de kit").Range("c2").PasteSpecial Paste:=xlPasteValues
'Worksheets("Prix Kit").Range("o2:o68").Copy
'Worksheets("liste de kit").Range("d2").PasteSpecial Paste:=xlPasteValues

Worksheets("liste de kit").Activate

For a = 2 To count

If Range("d" & a) = 0 Then

'MsgBox "zero"

Worksheets("Prix Kit").Range("m" & a).Copy
Worksheets("liste de kit").Range("d" & a).PasteSpecial Paste:=xlPasteValues

Else

If Worksheets("Prix Kit").Range("o" & a) < Worksheets("prix kit").Range("m" & a) Then

Worksheets("Prix Kit").Range("m" & a).Copy
Worksheets("liste de kit").Range("d" & a).PasteSpecial Paste:=xlPasteValues

Else

Worksheets("Prix Kit").Range("o" & a).Copy
Worksheets("liste de kit").Range("d" & a).PasteSpecial Paste:=xlPasteValues

End If

End If

Next a

End Sub

@Quadruple_Pawn 

 

thank you that worked