• DİKKAT

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

Macro da hata

mersilen

Destek Ekibi
Destek Ekibi
Katılım
31 Aralık 2009
Mesajlar
1,105
Excel Vers. ve Dili
excel 2007 türkçe
Excel Vers. ve Dili Ofis 2003
Merhabalar

Aşağıdaki makro hata veriyor
formül olarak kullanınca sorun olmuyor
Kodu nasıl düzenlememiz lazım?
Kod:
Sub tarihfarkı()
    'ActiveCell.FormulaR1C1 ="=24*60*60*(SUBSTITUTE(RC[-7],"" ttyyttt"","""")*1-SUBSTITUTE(R[1]C[-7],"" -"","""")*1)

For i = 20 To 40
    Cells(i, "I") = (WorksheetFunction.Substitute(Cells(i, "a"), "-", "") * 1)
    Cells(i, "J") = (WorksheetFunction.Substitute(Cells(i + 1, "a"), "-", "") * 1)
    Cells(i, "H") = 24 * 60 * 60 * (WorksheetFunction.Substitute(Cells(i, "a"), "-", "") * 1) - (WorksheetFunction.Substitute(Cells(i + 1, "a"), "-", "") * 1)
Next i
End Sub

Sub cdate1()
Range("a14") = CLng(CDate(Range("a20").Value))
Range("a13") = (CDate(Range("a20").Value))
Range("a11") = CLng(CDate(Range("a20").Value)) - CLng(CDate(Range("a21").Value))

End Sub
 

Ekli dosyalar

Son düzenleme:
Dosyanızın içi boş. Yeniden eklermisiniz.
 
Kusura bakmayın
Dosyayı yeniden 1. mesaja ekledim.
 
Aşağıdaki gibi cdate fonksiyonunu ilave edin.

Kod:
Cells(i, "I") = CDate(WorksheetFunction.Substitute(Cells(i, "a"), "-", ""))
Cells(i, "J") = CDate(WorksheetFunction.Substitute(Cells(i + 1, "a"), "-", ""))
Cells(i, "H") = 86400 * Round((CDate(Cells(i, "I")) - CDate(Cells(i, "J"))), 4)
 
Levent hocam kod hata veriyor

Kod:
Sub tarihfarkı3()
Dim i As Integer

For i = 20 To 40
Cells(i, "I") = CDate(WorksheetFunction.Substitute(Cells(i, "a"), "-", ""))
Cells(i, "J") = CDate(WorksheetFunction.Substitute(Cells(i + 1, "a"), "-", ""))
Cells(i, "H") = 86400 * Round((CDate(Cells(i, "I")) - CDate(Cells(i, "J"))), 4)
Next i

End Sub
 

Ekli dosyalar

Geri
Üst