Hi,
Looking for some help on the below code. Instead of adding just a new sheet Set (ws = y.Sheets.Add) (Sheet1, Sheet2...) I need to create the new sheet with a name from a specific range. The range is the adjacent cells/column from "E2:E33"
Sub CopyData()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim ws As Worksheet
Dim x As Workbook
Dim y As Workbook
Dim rngURL As Range
Dim cll As Range
Set rngURL = Worksheets("data_pull").Range("E2:E33")
On Error GoTo errHandler
For Each cll In rngURL
DoEvents
Set x = Workbooks.Open(cll.Value)
Set y = ThisWorkbook
Set ws = y.Sheets.Add
x.Sheets("data_paste").Cells.Copy
ws.Cells.PasteSpecial
ws.Cells.Copy
ws.Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
Application.CutCopyMode = False
x.Close
Next
errHandler:
If Err.Number <> 0 Then MsgBox "There was an error." & vbNewLine & "Error " & Err.Number & vbTab & Err.Description, vbOKOnly, "Error"
Application.DisplayAlerts = True
Set x = Nothing
Set y = Nothing
Set ws = Nothing
Application.ScreenUpdating = True
End Sub
Many Thanks in Advance
Looking for some help on the below code. Instead of adding just a new sheet Set (ws = y.Sheets.Add) (Sheet1, Sheet2...) I need to create the new sheet with a name from a specific range. The range is the adjacent cells/column from "E2:E33"
Sub CopyData()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim ws As Worksheet
Dim x As Workbook
Dim y As Workbook
Dim rngURL As Range
Dim cll As Range
Set rngURL = Worksheets("data_pull").Range("E2:E33")
On Error GoTo errHandler
For Each cll In rngURL
DoEvents
Set x = Workbooks.Open(cll.Value)
Set y = ThisWorkbook
Set ws = y.Sheets.Add
x.Sheets("data_paste").Cells.Copy
ws.Cells.PasteSpecial
ws.Cells.Copy
ws.Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
Application.CutCopyMode = False
x.Close
Next
errHandler:
If Err.Number <> 0 Then MsgBox "There was an error." & vbNewLine & "Error " & Err.Number & vbTab & Err.Description, vbOKOnly, "Error"
Application.DisplayAlerts = True
Set x = Nothing
Set y = Nothing
Set ws = Nothing
Application.ScreenUpdating = True
End Sub
Many Thanks in Advance