I have a "Master" workbook and worksheets in it. Sometime I have two a worksheet tab named "Helper" and "Summary", but sometime I have three worksheets in it (like "Analyze", "Helper" and "Summary").
In the 'Temp' folder I have between 80 and 100 workbooks (all depends on the current month).
I want to import a specific Worksheet tab name into my master book from multiple closed workbooks in a defined/selected folder, but there are three conditions.
Conditions
1. I want to enter the name of the worksheet in the cell 'D6' to the 'helper' worksheet. This Sheet name tab, VBA macro should be used to determine which worksheet should be imported.
2. Import all data contained in the worksheet as values without formulas.
3. The imported worksheet should be named as the file name of the workbook but without the year and extension.
For example: Worksheets are named as a monthNumber-years. This '1-2019' is the month of January 2019
I want to import the Sheet "1-2019" without the formulas (The name of this worksheet is placed in the 'D6' cell on the "helper" worksheet. Note: The Data Validation drop-down menu is set in this cell).
This is variable and every month I will change this data.
Some of the workbooks in the defined folder are:
- Surname1-Name_2019.xlsx
- Surname2-Name_2019.xlsx
- Surname3-2ndSurname-Name_2019.xlsx
I want the three "1-2019" imported worksheets are named as:
- Surname1-Name
- Surname2-Name
- Surname3-2ndSurname-Name
I have this VBA macro and this macro works.
But I want to avoid the extension of the file in the name of the copied worksheet. Also if it is possible to import without formulas and use 'D6' cell.
Can someone correct this VBA macro above? I'm using excel 2010.
or
I would be very grateful if someone has a VBA macro that has an input form for selecting a folder and enter a name for a specific sheet and meets these three conditions above.
This is too hard for me, can someone please help?
In the 'Temp' folder I have between 80 and 100 workbooks (all depends on the current month).
I want to import a specific Worksheet tab name into my master book from multiple closed workbooks in a defined/selected folder, but there are three conditions.
Conditions
1. I want to enter the name of the worksheet in the cell 'D6' to the 'helper' worksheet. This Sheet name tab, VBA macro should be used to determine which worksheet should be imported.
2. Import all data contained in the worksheet as values without formulas.
3. The imported worksheet should be named as the file name of the workbook but without the year and extension.
For example: Worksheets are named as a monthNumber-years. This '1-2019' is the month of January 2019
I want to import the Sheet "1-2019" without the formulas (The name of this worksheet is placed in the 'D6' cell on the "helper" worksheet. Note: The Data Validation drop-down menu is set in this cell).
This is variable and every month I will change this data.
Some of the workbooks in the defined folder are:
- Surname1-Name_2019.xlsx
- Surname2-Name_2019.xlsx
- Surname3-2ndSurname-Name_2019.xlsx
I want the three "1-2019" imported worksheets are named as:
- Surname1-Name
- Surname2-Name
- Surname3-2ndSurname-Name
I have this VBA macro and this macro works.
But I want to avoid the extension of the file in the name of the copied worksheet. Also if it is possible to import without formulas and use 'D6' cell.
Rich (BB code):
Sub ImportSheetFromMultipleWbk()
Dim myDir As String
Dim fn As String
myDir = "C:\Temp" 'defined path
fn = Dir(myDir & "\*.xlsx") 'format file
Do While fn <> ""
With Workbooks.Open(myDir & "\" & fn)
With .Sheets("1-2019") 'How to Pull this information 1-2019 from D6 cell from "helper" worksheet and import this named sheet?
'---------------
' If possible import all data in worksheet as values without formulas
'---------------
.Name = "" & fn & "" 'name of imported sheet like name.xlsx (Is possible without year and extension?)
.Copy After:=ThisWorkbook.Sheets(1)
'.Copy After:=ThisWorkbook.Sheets(3)
End With
.Close False
End With
fn = Dir
Loop
End Sub
or
I would be very grateful if someone has a VBA macro that has an input form for selecting a folder and enter a name for a specific sheet and meets these three conditions above.
This is too hard for me, can someone please help?