Hi Everyone, can anyone teach me how to copy the data from the folderpath to new workbook without open the folderpath
below is my current code
Sub AAA()
Application.ScreenUpdating = False
Dim NewSheet As Workbook
Dim FolderPath As String
Dim NRow As Integer
FolderPath = Application.GetOpenFilename(filefilter:="Excel Files (*.xl*), *.xl*")
If FolderPath = "False" Then
MsgBox "No file selected."
Exit Sub
End If
Workbooks.Open (FolderPath)
NRow = Range("F1").CurrentRegion.Rows.Count
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("F:G").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Columns("O:T").Select
Selection.Delete Shift:=xlToLeft
Columns("P:Q").Select
Selection.Delete Shift:=xlToLeft
Columns("Q:R").Select
Selection.Delete Shift:=xlToLeft
Columns("R:R").Select
Selection.Delete Shift:=xlToLeft
Columns("S:S").Select
Selection.Delete Shift:=xlToLeft
Columns("T:AK").Select
Selection.Delete Shift:=xlToLeft
Range("A1", "S" & NRow).Range("A1", "S" & NRow).Copy
Workbooks.Add
Range("A1", "S" & NRow).PasteSpecial
End Sub
Bookmarks