- Katılım
- 15 Mart 2005
- Mesajlar
- 42,307
- Excel Vers. ve Dili
- Microsoft 365 Tr-En 64 Bit
Deneyiniz.
C++:
Option Explicit
Sub Import_Data()
Dim K1 As Workbook, S1 As Worksheet, S2 As Worksheet, K2 As Workbook, S3 As Worksheet
Dim File_Path As String, My_File As String, XL_App As Object, My_Date As String
Dim Find_Store As Range, Store_Name As String, Process_Time As Double
Process_Time = Timer
Set K1 = ThisWorkbook
Set XL_App = VBA.CreateObject("Excel.Application")
XL_App.Visible = False
File_Path = K1.Path & "\"
My_File = Dir(File_Path & "*.xls*")
While My_File <> ""
If My_File <> K1.name Then
Set K2 = XL_App.Workbooks.Open(File_Path & My_File)
Set S3 = K2.Sheets(1)
My_Date = Format(S3.Range("A8").Value, "dd.mm.yyyy")
Set S1 = K1.Sheets(CStr(My_Date))
Set S2 = K1.Sheets(CStr(My_Date) & " Gider")
Store_Name = VBA.Split(My_File, " ")(0)
Set Find_Store = S1.Range("A:A").Find(Store_Name, , , xlWhole)
If Not Find_Store Is Nothing Then
S1.Cells(Find_Store.Row, 2).Value = IIf(S3.Range("D8").Value = Empty, 0, S3.Range("D8").Value)
S1.Cells(Find_Store.Row, 3).Value = IIf(S3.Range("D9").Value = Empty, 0, S3.Range("D9").Value)
S1.Cells(Find_Store.Row, 4).Value = IIf(S3.Range("D10").Value = Empty, 0, S3.Range("D10").Value)
S1.Cells(Find_Store.Row, 5).Value = IIf(S3.Range("D11").Value = Empty, 0, S3.Range("D11").Value)
S1.Cells(Find_Store.Row, 6).Value = IIf(S3.Range("D12").Value = Empty, 0, S3.Range("D12").Value)
S1.Cells(Find_Store.Row, 8).Value = WorksheetFunction.Sum(S3.Range("K9:K12"))
S1.Cells(Find_Store.Row, 9).Value = WorksheetFunction.Sum(S3.Range("K13:K15"))
S1.Cells(Find_Store.Row, 10).Value = IIf(S3.Range("K8").Value = Empty, 0, S3.Range("K8").Value)
End If
Set Find_Store = S2.Range("A:A").Find(Store_Name, , , xlWhole)
If Not Find_Store Is Nothing Then
S2.Cells(Find_Store.Row, 2).Value = S3.Range("F9").Value
S2.Cells(Find_Store.Row, 3).Value = IIf(S3.Range("K9").Value = Empty, 0, S3.Range("K9").Value)
S2.Cells(Find_Store.Row, 4).Value = S3.Range("F10").Value
S2.Cells(Find_Store.Row, 5).Value = IIf(S3.Range("K10").Value = Empty, 0, S3.Range("K10").Value)
S2.Cells(Find_Store.Row, 6).Value = S3.Range("F11").Value
S2.Cells(Find_Store.Row, 7).Value = IIf(S3.Range("K11").Value = Empty, 0, S3.Range("K11").Value)
S2.Cells(Find_Store.Row, 8).Value = S3.Range("F12").Value
S2.Cells(Find_Store.Row, 9).Value = IIf(S3.Range("K12").Value = Empty, 0, S3.Range("K12").Value)
S2.Cells(Find_Store.Row, 10).Value = S3.Range("F13").Value
S2.Cells(Find_Store.Row, 11).Value = IIf(S3.Range("K13").Value = Empty, 0, S3.Range("K13").Value)
S2.Cells(Find_Store.Row, 12).Value = S3.Range("F14").Value
S2.Cells(Find_Store.Row, 13).Value = IIf(S3.Range("K14").Value = Empty, 0, S3.Range("K14").Value)
S2.Cells(Find_Store.Row, 14).Value = S3.Range("F15").Value
S2.Cells(Find_Store.Row, 15).Value = IIf(S3.Range("K15").Value = Empty, 0, S3.Range("K15").Value)
End If
K2.Close 0
End If
My_File = Dir
Wend
XL_App.Quit
Set XL_App = Nothing
Set K1 = Nothing
Set S1 = Nothing
Set S2 = Nothing
Set K2 = Nothing
Set S3 = Nothing
MsgBox "Depo verileri güncellenmiştir." & vbCr & vbCr & _
"İşlem süresi ; " & Format(Timer - Process_Time, "0.00") & " Saniye", vbInformation
End Sub