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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,216,119
Messages
6,128,946
Members
449,480
Latest member
yesitisasport

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