lundi 31 juillet 2017

Write value from 12 column on another worksheet if two conditions in columns 4 and 8 are true

Sub CreateTable() 
Dim bf As Boolean
Dim aTable(), aRes()
Dim i As Long, k As Long, n As Long
  With Worksheets("DOHADNÉ POLOŽKY")   ' List s tabulkou, kde se hleda
    i = .Cells(.Rows.Count, "A").End(xlUp).row
    aTable = .Range("A1:P" & i).Value ' tabulka do pole

    ReDim aRes(1 To i + 1, 1 To 1) ' velikost pole
        End With



For i = 1 To UBound(aTable)  ' od 1 do poctu radky tabulky
    If aTable(i, 1) <> Empty Then ' kdyz neni prazdna
        If aTable(i, 4) = "Depo" And aTable(i, 8) = "CZK" Then


                    aTable(i, 12) = aRes(i, 1): i = i + 1
                                           End If
                                End If
Next i
' upload vysledku na list do sloupce J
Worksheets("List1").Range("A1").Resize(UBound(aRes), 1).Value = aRes
Range("A1").Select
ActiveCell.FormulaR1C1 = "KUK"

End Sub

Something is wrong. It has no errors, but it doesn't write value in array I think. So the result on Worksheet("List1") is just empty.

Aucun commentaire:

Enregistrer un commentaire