Greetings,
Yesterday I had asked about copying worksheets from many workbooks to a new workbook, and have each worksheet on a separate page. I got some outstanding help with the following code:
Sub mcrOMA_Get_Data()
Dim cel As Range
Dim FileName, ws As Worksheet
Dim rng As Range
Dim destWB As Workbook
Dim pPath As String
Dim ShellApp As Object
Set ShellApp = CreateObject("Shell.Application").BrowseForFolder(0, Prompt, 0, OpenAt)
On Error Resume Next
pPath = ShellApp.self.Path
On Error GoTo 0
Application.ScreenUpdating = 0
If pPath = "" Then
' Cancel was selected
MsgBox "Stopping because you did not select a Folder"
Exit Sub
End If
I = 1
Workbooks.Add
Set destWB = ActiveWorkbook
With CreateObject("scripting.filesystemobject")
For Each FileName In .getfolder(pPath).Files
With Workbooks.Open(FileName)
For Each ws In .Sheets
ws.Copy destWB.Sheets(I)
I = I + 1
Next
.Close True
End With
Next
End With
Application.ScreenUpdating = 1
End Sub
What I would like to do now is modify that existing code to have every worksheet from every workbook, copied to a new workbook, but put all of them on the same page, instead of separate pages. I know asked this once before, but it was for a different application, with a different style of worksheets, and I could not figure out how to make it work in this particular application.
Would it be as easy as changing the line of code that reads
And replace the letter I with the digit 1?
Or do I need to increment the rows as well so they don't all write over top of each other?
As you can see, having a little issue with this, but I do appreciate any assistance.
Bookmarks