Warderbrad
New Member
- Joined
- May 8, 2023
- Messages
- 1
- Office Version
- 2021
- Platform
- Windows
Hello all,
I have a tool I am writing and I am trying to load in raw data from another file to be analyzed.
So I have:
Tool.xlsx
Raw Data 1.xlsx (always just one sheet within the workbook but file name is variable)
Raw Data 2.csv (filename is variable)
My intent to identify the file names is to use the GetOpenFilename method. One of the difficulties I have run into is that I need just the values, no formulas or formatting and some of the cells are merged in the Raw Data 1 file.
I want to use a macro in Tools to load in each of the raw data files into specific sheets which are hidden so that formulas on other sheets can reference them.
Raw Data 1 -> Raw Data PDF worksheet
Raw Data 2 -> Raw SyteLine worksheet
Here is the code so far for copying the Raw Data 1. It is not pasting as I would expect. Any help would be appreciated.
I have a tool I am writing and I am trying to load in raw data from another file to be analyzed.
So I have:
Tool.xlsx
Raw Data 1.xlsx (always just one sheet within the workbook but file name is variable)
Raw Data 2.csv (filename is variable)
My intent to identify the file names is to use the GetOpenFilename method. One of the difficulties I have run into is that I need just the values, no formulas or formatting and some of the cells are merged in the Raw Data 1 file.
I want to use a macro in Tools to load in each of the raw data files into specific sheets which are hidden so that formulas on other sheets can reference them.
Raw Data 1 -> Raw Data PDF worksheet
Raw Data 2 -> Raw SyteLine worksheet
Here is the code so far for copying the Raw Data 1. It is not pasting as I would expect. Any help would be appreciated.
VBA Code:
Sub testimport()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wb As Workbook
Dim activeWB As Workbook
Dim FilePath As String
Set activeWB = Application.ActiveWorkbook
FilePath = Application.GetOpenFilename(FileFilter:="Excel files (*.xlsx*), *.xlsx*", Title:="Choose an Excel file to open", MultiSelect:=False)
If FilePath <> "" Then
On Error Resume Next
Set wb = Application.Workbooks.Open(FilePath)
wb.Worksheets(Sheet1).Copy
activeWB.Range(A1).PasteSpecial (xlPasteValues)
wb.Close False
End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub