hondahawkrider
New Member
- Joined
- Nov 12, 2015
- Messages
- 10
I have a macro that pulls in multiple (filtered) excel sheets to seperate tab/worksheets
It works great and I use it a lot - but I have 2 problems now ... The new files that are getting imported have their worksheet named Report. So when they get imported the multiple files appear as worksheet/tabs named as Report, Report (2), and Report (3) ... Instead of Importing them as report - can the worksheets use the file name instead the worsheet name ? .. My other concern is the files are descriptively names with 27 characters with the date added at the end.. Fairly sure there is a character limitation of the the length, so if the file name can be used, is there a way to count in X number of character or start from the end..
Thanks in advance....
VBA Code:
Sub CopySheets()
'no filter sheets
Application.ScreenUpdating = False
Dim fd As FileDialog, lRow As Long, vSelectedItem As Variant, srcWB As Workbook, desWB As Workbook
Set desWB = ThisWorkbook
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = True
If .Show = -1 Then
For Each vSelectedItem In .SelectedItems
Set srcWB = Workbooks.Open(vSelectedItem)
Sheets(1).Copy after:=desWB.Sheets(desWB.Sheets.Count)
srcWB.Close False
Next
Else
End If
End With
Application.ScreenUpdating = True
End Sub
Thanks in advance....