SamarthSalunkhe
Board Regular
- Joined
- Jun 14, 2021
- Messages
- 96
- Office Version
- 2016
- Platform
- Windows
Hi All,
I am trying to use the below code to import data from another workbook, I am not getting any errors but the code is not importing data.
End Sub
I am trying to use the below code to import data from another workbook, I am not getting any errors but the code is not importing data.
VBA Code:
Sub Get_Data_From_File()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets(1).Activate
ActiveSheet.PivotTables("PivotTable4").PivotSelect "", xlDataAndLabel, True
Selection.Copy
Sheets("Sheet1").Range("C4").PasteSpecial xlPasteValues
Application.CutCopyMode = False
OpenBook.Close False
End If
Application.ScreenUpdating = True
End Sub