Dear all
Good day
i am having problem on copying data from 3 excel file to 1 master file.
i want to copy from source excel file to 1 master file
this is my code :
Sub CopyData()
Dim Fname As String
Dim scwbk As Workbook
Dim dswbk As Workbook
Dim a As Range
Dim b As Range
Dim c As Range
Dim d As Range
Set dswbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set scwbk = Workbooks.Open(Fname)
Set a = scwbk.Sheets("summary").Range("d4")
Set b = dswbk.Sheets("DF_data").Range("d4")
Set c = dswbk.Sheets("DF_data").Range("t4")
Set d = dswbk.Sheets("DF_data").Range("ar4")
If a = b Then
scwbk.Sheets("summary").Range("$d8:$d28").Copy dswbk.Sheets("DF_data").Range("$d8:$d28")
scwbk.Sheets("summary").Range("$e8:$e28").Copy dswbk.Sheets("DF_data").Range("$f8:$f28")
ElseIf a = c Then
scwbk.Sheets("summary").Range("$d8:$d28").Copy dswbk.Sheets("DF_data").Range("$t8:$t28")
ElseIf a = d Then
scwbk.Sheets("summary").Range("$d8:$d28").Copy dswbk.Sheets("DF_data").Range("$ar8:$ar28")
End If
scwbk.Close False
End Sub
at my highlighted code, the one i need to copy is from columns e(from source excel file) to columns f(at master excel file) but the data that been copied is from columns f(from source excel file)
hope someone can assist me with this problem
Thank you
Good day
i am having problem on copying data from 3 excel file to 1 master file.
i want to copy from source excel file to 1 master file
this is my code :
Sub CopyData()
Dim Fname As String
Dim scwbk As Workbook
Dim dswbk As Workbook
Dim a As Range
Dim b As Range
Dim c As Range
Dim d As Range
Set dswbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set scwbk = Workbooks.Open(Fname)
Set a = scwbk.Sheets("summary").Range("d4")
Set b = dswbk.Sheets("DF_data").Range("d4")
Set c = dswbk.Sheets("DF_data").Range("t4")
Set d = dswbk.Sheets("DF_data").Range("ar4")
If a = b Then
scwbk.Sheets("summary").Range("$d8:$d28").Copy dswbk.Sheets("DF_data").Range("$d8:$d28")
scwbk.Sheets("summary").Range("$e8:$e28").Copy dswbk.Sheets("DF_data").Range("$f8:$f28")
ElseIf a = c Then
scwbk.Sheets("summary").Range("$d8:$d28").Copy dswbk.Sheets("DF_data").Range("$t8:$t28")
ElseIf a = d Then
scwbk.Sheets("summary").Range("$d8:$d28").Copy dswbk.Sheets("DF_data").Range("$ar8:$ar28")
End If
scwbk.Close False
End Sub
at my highlighted code, the one i need to copy is from columns e(from source excel file) to columns f(at master excel file) but the data that been copied is from columns f(from source excel file)
hope someone can assist me with this problem
Thank you