mardi 29 juin 2021

loop gives me error. If i have error i wana go for next cell

i have this code. I need a help. When in pivot tabel3 vba couldnt find this: Sheets("EXO").Range("N" & y).Value i wana go for next cell until vba do not find this this Sheets("EXO").Range("N" & y).Value and after then vba should do copy and paste part of loop Could u please help me ?

Sub FILL_vALUES_EXO()
i = 1
y = 9
rng = Application.WorksheetFunction.CountA(Worksheets("EXO").Range("N9:N67"))


Do While i < rng
    
    
    Application.CutCopyMode = False
    
    Sheets("EXO").Range("N" & y).copy
    ActiveSheet.PivotTables("PivotTable3").PivotFields("RootCause").ClearAllFilters
   ActiveSheet.PivotTables("PivotTable3").PivotFields("RootCause").CurrentPage = _
       Sheets("EXO").Range("N" & y).Value
      

    
    Range("B6").Select
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.copy
    Range("O" & y).Select
    ActiveSheet.Paste

   Range("O4").Select
    Application.CutCopyMode = False
    Selection.copy
    Range("O" & y & ":R" & y).Select
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
y = y + 1
i = i + 1

end sub

Aucun commentaire:

Enregistrer un commentaire