Mình có đoạn code, lấy dữ liệu từ nhiều file excel về một file excel. Nhưng đoạn code lại lấy công thức sang, mình muốn đoạn code lấy giá trị sang thôi. Mong các bạn giúp đỡ
Sub test()
Dim FSO As Object, FileItem As Object, i As Integer, wbmain As Workbook, wb As Workbook
Set wbmain = ThisWorkbook
Set FSO = CreateObject("Scripting.FileSystemObject")
With wbmain
For Each FileItem In FSO.GetFolder(wbmain.Path).Files
If FileItem.Name <> "Tong hop.xlsx" And Left(FileItem.Name, 1) <> "~" Then
i = i + 1
Set wb = Workbooks.Open(FileItem.Path)
wb.Sheets("Tram 1").Range("D2:E34").Copy .ActiveSheet.Cells(4, i * 2)
.ActiveSheet.Cells(2, i * 2) = Left(FileItem.Name, Len(FileItem.Name) - 5)
wb.Close False
End If
Next
End With
End SubSub test()
Dim FSO As Object, FileItem As Object, i As Integer, wbmain As Workbook, wb As Workbook
Set wbmain = ThisWorkbook
Set FSO = CreateObject("Scripting.FileSystemObject")
With wbmain
For Each FileItem In FSO.GetFolder(wbmain.Path).Files
If FileItem.Name <> "Tong hop.xlsx" And Left(FileItem.Name, 1) <> "~" Then
i = i + 1
Set wb = Workbooks.Open(FileItem.Path)
wb.Sheets("Tram 1").Range("D2:E34").Copy .ActiveSheet.Cells(4, i * 2)
.ActiveSheet.Cells(2, i * 2) = Left(FileItem.Name, Len(FileItem.Name) - 5)
wb.Close False
End If
Next
End With
End Sub
Sub test()
Dim FSO As Object, FileItem As Object, i As Integer, wbmain As Workbook, wb As Workbook
Set wbmain = ThisWorkbook
Set FSO = CreateObject("Scripting.FileSystemObject")
With wbmain
For Each FileItem In FSO.GetFolder(wbmain.Path).Files
If FileItem.Name <> "Tong hop.xlsx" And Left(FileItem.Name, 1) <> "~" Then
i = i + 1
Set wb = Workbooks.Open(FileItem.Path)
wb.Sheets("Tram 1").Range("D2:E34").Copy .ActiveSheet.Cells(4, i * 2)
.ActiveSheet.Cells(2, i * 2) = Left(FileItem.Name, Len(FileItem.Name) - 5)
wb.Close False
End If
Next
End With
End SubSub test()
Dim FSO As Object, FileItem As Object, i As Integer, wbmain As Workbook, wb As Workbook
Set wbmain = ThisWorkbook
Set FSO = CreateObject("Scripting.FileSystemObject")
With wbmain
For Each FileItem In FSO.GetFolder(wbmain.Path).Files
If FileItem.Name <> "Tong hop.xlsx" And Left(FileItem.Name, 1) <> "~" Then
i = i + 1
Set wb = Workbooks.Open(FileItem.Path)
wb.Sheets("Tram 1").Range("D2:E34").Copy .ActiveSheet.Cells(4, i * 2)
.ActiveSheet.Cells(2, i * 2) = Left(FileItem.Name, Len(FileItem.Name) - 5)
wb.Close False
End If
Next
End With
End Sub