0

i have problem with this code. I never used do while 2 times in code. Is it even possible to it ? Anyway i am sending my code the vba giving me mistake in second loop (do while art<zm+1). Please help me to fix it. I mean i want first to filtered in sheet(sheet3) product id from sheet (kod) and after then copied and paste to another sheet until i will not have empty range (a a) and in second loop i want to it until i will not empty value in L column.

Sub production()
Dim art As Long
art = 2
y = 2
og = 1
ss = Application.WorksheetFunction.CountA(Workbooks("design.xlsm").Worksheets("KOD").Range("A:A"))
zm = Application.WorksheetFunction.CountA(Workbooks("design.xlsm").Worksheets("sheet4").Range("l:l"))

Do While og < ss + 1
Sheets("Sheet3").Select
    ActiveSheet.Range("$A$5:$l$100000").AutoFilter Field:=2, Criteria1:= _
        Sheets("KOD").Cells(og, 1).Value
        
    Sheets("sheet3").Range("a1").Select
    Range(Selection, Selection.End(xlToRight).End(xlDown)).copy Sheets("sheet4").Range("a1")
        

    
    
    zm = Application.WorksheetFunction.CountA(Workbooks("design.xlsm").Worksheets("sheet4").Range("l:l"))
    Sheets("sheet4").Select
    Range("Q30:AR30").Select
    Selection.ClearContents
                Do While art < zm + 1
                x = Sheets("SHEET4").Range("q29:Aq29").Find(Range("l" & art), LookAt:= _
                    xlWhole).Column - 1
                Sheets("SHEET4").Range("C" & y).copy Sheets("SHEET4").Range("A30").Offset(0, x)
                art = art + 1
                y = y + 1
    Loop

Sheets("sheet4").Range("q30", "aq30").Select
 Selection.copy
Sheets("Sheet1").Select
Range("A2:A44").Select
Columns("A:A").Select
Selection.Find(Sheets("sheet4").Range("o30"), After:=ActiveCell, LookIn:= _
    xlFormulas2, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False).Offset(2, 2).Select
ActiveSheet.Paste
        

Loop

End Sub
Salim
  • 11
  • 1
  • 5

0 Answers0