Copy and paste contents from two worksheets to another workbook sheet

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi Team,

I am trying to use the below code to copy data from two worksheets and paste it in the different workbook sheet, however while doing this only one work sheet is getting copy and pasted in the destination worksheet, however second worksheet doesn get copy pasted, below code for your reference and please let me know if i am missing some part,

Sub Import1()
'
' Import Macro
'
Application.ScreenUpdating = False

'************************to browse and select the file*****************************
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),")


If strFileToOpen = False Then
MsgBox "No file selected.", vbExclamation, "Sorry!"
Exit Sub
Else
Set Wb = Workbooks.Open(strFileToOpen)
End If

Dim lo As ListObject
Dim icol As Long

ThisWorkbook.Activate
Sheets("Template").Select


Wb.Activate
Sheets("Learning Admin").Select
Worksheets("Learning Admin").Range("A1").AutoFilter Field:=2, Criteria1:= _
"=Ready", Operator:=xlOr, Criteria2:="=Work in Progress"

Range("A2:J2", Range("A65536:J65536").End(xlUp)).Select
Selection.Copy
ThisWorkbook.Activate
ActiveSheet.Paste Destination:=Worksheets("Input Data").Range("A2")

Wb.Activate
Sheets("BeSpoke").Select
Worksheets("BeSpoke").Range("A1").AutoFilter Field:=2, Criteria1:= _
"=Ready", Operator:=xlOr, Criteria2:="=Work in Progress"

Range("A2:J2", Range("A65536:J65536").End(xlUp)).Select
Selection.Copy
ThisWorkbook.Activate
Worksheets("Input Data").Select
ActiveSheet.Paste Destination:=Worksheets("Input Data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)


End Sub


it will be helpfull if a speedy response is recieved many thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Remove (for debugging) the initial Application.ScreenUpdating = False, then execute your code step by step and observe what is going on.
To step through the code, select the macro in the vba IDE and use F8: each F8 will execute the highlighted instruction; check on the worksheet what happens at each instrucion.
If what you see doesn't swithch on the light then explain what you see: which area is selected and then copied, wich is the initial situation with sheet "Input Data", what happens on Paste.
Look also to be sure that the second block is not written much below the initial block (and thus are not immediately visible)

Bye
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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