Macro to copy data from one sheet to another

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have a macro below to copy data from sheets 996235 & 078925

If Am on aon shet Statement, the macro copies the data from sheets 996235 & 078925 and pastes the data to ssheet "Statement"

However if I run the macro from another sheet the data is not pastes on to sheet Statement

t would be appreciated if someone could amend my code


Code:
 Sub Copy_Statement()
Sheets("statement").Range("A1:R2000").ClearContents
Application.ScreenUpdating = False
     Sheets("Import 996235").UsedRange.Copy Destination:=ThisWorkbook.Sheets("statement").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Sheets("Import 078925").UsedRange.Copy Destination:=ThisWorkbook.Sheets("statement").Range("A" & Rows.Count).End(xlUp).Offset(1)
 Application.ScreenUpdating = True

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I ran your code and it worked perfectly fine even from other sheets. What type of error you're getting?
 

Attachments

  • 1675346271711.png
    1675346271711.png
    2.6 KB · Views: 5
Upvote 0
The Sheet "Statement" is blank when running the macro from another Sheet

Could this be because sheet 078925 is blank ?
 
Upvote 0
Thanks for your reply

I sorted out the issue. The source data was importing the data from the incorrect folder
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,656
Members
449,045
Latest member
Marcus05

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