Copy and paste contents from two worksheets to another workbook sheet

Satheesh9012

New Member
Joined
Mar 19, 2021
Messages
40
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,278
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,836
Messages
5,766,716
Members
425,373
Latest member
ndiejennrrd

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
Top