Code:
Sub sumcopy()
'April/2017
Dim first_day, lasy_day, month, year As Integer
Dim mmonth As String
Dim source_file As String
month = InputBox("Please enter the Month", "TCU//QNB Finansbank")
year = Worksheets("Macro").Cells(6, 2)
'Hangi ay hangi sayfada onu buluyoruz.
If month = 1 Then
mmonth = "January"
ElseIf month = 2 Then
mmonth = "February"
ElseIf month = 3 Then
mmonth = "March"
ElseIf month = 4 Then
mmonth = "April"
ElseIf month = 5 Then
mmonth = "May"
ElseIf month = 6 Then
mmonth = "June"
ElseIf month = 7 Then
mmonth = "July"
ElseIf month = 8 Then
mmonth = "August"
ElseIf month = 9 Then
mmonth = "September"
ElseIf month = 10 Then
mmonth = "October"
ElseIf month = 11 Then
mmonth = "November"
ElseIf month = 12 Then
mmonth = "December"
End If
'target file
target_path = "G:\HOME\MALIKONT\_Hazine_Kontrol\TCU_" & yil & "\Bilanço_Kontrolleri\Core_Pozisyon\Core Pozisyon Aylık Özet"
target_mainfile = "G:\HOME\MALIKONT\_Hazine_Kontrol\TCU_" & yil & "\Bilanço_Kontrolleri\Core_Pozisyon\" & "Core Pozisyon Özet" & ".xlsm"
Dim Column, Column_2 As Integer
wb = ActiveWorkbook.Name
'target file
If aay = "January" Then
Workbooks(wb).Worksheets(1).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "February" Then
Workbooks(wb).Worksheets(2).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "March" Then
Workbooks(wb).Worksheets(3).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "April" Then
Workbooks(wb).Worksheets(4).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "May" Then
Workbooks(wb).Worksheets(5).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "June" Then
Workbooks(wb).Worksheets(6).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "July" Then
Workbooks(wb).Worksheets(7).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "August" Then
Workbooks(wb).Worksheets(8).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "September" Then
Workbooks(wb).Worksheets(9).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "October" Then
Workbooks(wb).Worksheets(10).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "November" Then
Workbooks(wb).Worksheets(11).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
ElseIf aay = "December" Then
Workbooks(wb).Worksheets(12).Activate
ActiveSheet.Range("a4").Select
Range(Selection, Selection.End(xlToRight)).Select
sutun = Application.Count(Selection) + 2
End If
j = 2
Do Until ActiveSheet.Cells(3, j) = ""
first_day_date = Cells(3, j)
If Day(first_day_date) <= 9 Then
first_day = "0" & Day(first_day_date)
Else
first_day = Day(first_day_date)
End If
'source file
If month <= 9 Then
source_path = "G:\HOME\MALIKONT\_Hazine_Kontrol\TCU_" & yil & "\Bilanço_Kontrolleri\Core_Pozisyon\(0" & ay & ")_" & aay
source_file = source_path & "\CORE-MİZAN Pozisyon Kontrolü_" & yil & "-0" & ay & "-" & ilk_gun & ".xlsx"
Else
source_path = "G:\HOME\MALIKONT\_Hazine_Kontrol\TCU_" & yil & "\Bilanço_Kontrolleri\Core_Pozisyon\(" & ay & ")_" & aay
source_file = source_path & "\CORE-MİZAN Pozisyon Kontrolü_" & yil & "-" & ay & "-" & ilk_gun & ".xlsx"
End If
'open file
Workbooks.Open (source_file), ReadOnly:=True
wb_core = ActiveWorkbook.Name
'to get daily summary of poz
ActiveWorkbook.Worksheets("summary").Activate
i = 5
Do Until i = 24
If aay = "January" Then
Workbooks(wb).Worksheets(1).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "February" Then
Workbooks(wb).Worksheets(2).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "March" Then
Workbooks(wb).Worksheets(3).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "April" Then
Workbooks(wb).Worksheets(4).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "May" Then
Workbooks(wb).Worksheets(5).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "June" Then
Workbooks(wb).Worksheets(6).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "July" Then
Workbooks(wb).Worksheets(7).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "August" Then
Workbooks(wb).Worksheets(8).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "September" Then
Workbooks(wb).Worksheets(9).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "October" Then
Workbooks(wb).Worksheets(10).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "November" Then
Workbooks(wb).Worksheets(11).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
ElseIf aay = "December" Then
Workbooks(wb).Worksheets(Sheet12).Cells(i - 1, j).Value = Workbooks(wb_core).Worksheets("summary").Cells(i, 7).Value
End If
i = i + 1
Loop
Loop
Workbooks(wb).Save
End Sub
hi here is my code which i want to do open daily files and copy the exact same place to my main file my main file got the dates on Column like 01/01/2017 it supposed to do when i write the month like 01 open all the 01 daily files and copy the place which i wrote in the code and get them to the main file when i write the month number like 07 it only gets the first day of the month help please thanks