Import data from other sheet into hidden sheet

Warderbrad

New Member
Joined
May 8, 2023
Messages
1
Office Version
  1. 2021
Platform
  1. 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.

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
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top