mercredi 27 avril 2016

Excel VBA Copy one cell from some sheets and save on the another sheet

I have 5 sheets : graph, sheet1, sheet2, sheet3 and list. I have to copy the cell B3 from sheet1 and paste on graph in the cell C2, cell B3 from sheet2 to graph after B3 from sheet1 (cell C3) etc. But I can't touch the sheet list.

nbrows = Range("A" & rows.Count).End(xlUp).Row
For y = 2 To nbrows   
    Workbooks("JiraKPI.xlsm").Activate
    Worksheets(Worksheets("Sheet" & y).Range("B3").Copy
    Worksheets("Graph").Select
    If Range("C2") <> ("") Then
        Range("$D65536").End(xlUp).Offset(1, 0).Select
        Selection.PasteSpecial Paste:=xlPasteValues
    Else
        Range("C2").Select
        ActiveSheet.Paste
    End If
Next y

Aucun commentaire:

Enregistrer un commentaire