• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Döngü içinde toplama

Katılım
5 Temmuz 2011
Mesajlar
9
Excel Vers. ve Dili
Excel 3
İngilizce
Aşağıdaki kod ile 2 farklı dosyadan veri kopyalayıp 3. dosyaya yazdırıyorum.
Fakat sürekli 2. dosyanın verilerini yazıyor. Benim istediğim 1. dosyanın ve 2. dosyanın verilerini toplayıp 3. dosyaya yazması. Sonrada bu kodu 60 dosya için uyarlayacağım.

Kod:
Sub VERİ_AL()
Dim DOSYA_YOLU As String
Dim i As Integer
For i = 1 To 2
DOSYA_YOLU = ThisWorkbook.Path & "\[" & CStr(i) + ".xls]"
Range("H8").End(3).Offset(1).Value = Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C8")
Range("I8").End(3).Offset(1).Value = Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C9")
Range("J8").End(3).Offset(1).Value = Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C10")
Range("K8").End(3).Offset(1).Value = Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C11")
Range("L8").End(3).Offset(1).Value = Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C12")
Next

End Sub
 
Merhaba,

ilk satırı yazıyorum diğerlerini sen değiştirirsin.

Range("H8").End(3).Offset(1).Value = Range("H8").End(3).Offset(1).Value + Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C8")
 
Merhaba,

Kod:
Sub VERİ_AL()
Dim DOSYA_YOLU As String
Dim i As Integer
Dim sonsat As Double
sonsat = Range("H8").End(3).Offset(1).Row

For i = 1 To 2
    DOSYA_YOLU = ThisWorkbook.Path & "\[" & CStr(i) + ".xls]"
    Range("H" & sonsat).Value = Range("H" & sonsat).Value + Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C8")
    Range("I" & sonsat).Value = Range("I" & sonsat).Value + Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C9")
    Range("J" & sonsat).Value = Range("J" & sonsat).Value + Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C10")
    Range("K" & sonsat).Value = Range("K" & sonsat).Value + Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C11")
    Range("L" & sonsat).Value = Range("L" & sonsat).Value + Application.ExecuteExcel4Macro("'" & DOSYA_YOLU & "hesaplama'!R8C12")
Next

End Sub
 
Geri
Üst