Copy Rows from multiple Worksheets to another sheet based on date cell

yahavzarfati

New Member
Joined
Jun 17, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hi im new to VBA and can not get any progress on this one

i have 10 source worksheets and i need to copy all rows from the last 48 hours to target worksheet thet called "report sheet"
in all source sheet the date is on cell "a" and start from "a3", but the length of the row is not same on all source sheets
tha name of sorce sheet for example:
"unit1"
"unit 2"
"Events"

pleas halp me to start this project
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You said:
copy all rows from the last 48 hours

But then said Date is in column A not time
So, I assume you mean todays date and yesterday's Date

So, like Today is 6/17/2022
So, if script was run today, you would be looking for any cell in column A with 6/17/2022 Or 6/16/2022

Is this correct?
 
Upvote 0
One problem I might see in using a script like this:
Lets say you have a date in column A which is not today or yesterday
Then the script will not copy this row to the sheet named "report sheet"

So if your not working on a certain day the script will not pickup this row
I suggest you have a InputBox popup asking for the Date to search for.
And be careful when posting what you want. Spelling and Capitulation is important.
You said sheet named:
"report sheet"

Not:
"Report Sheet"
so is it really
"report sheet"
 
Upvote 0
yes you are right data is on column A not time
so if the script will not copy all rows thet date in column A which is not today or yesterday i think its well work for me

we work 24/7 and the main goal is to generate a daily report that contain all rows from 2 last days by one click for operators,
in the weekend we need to generate a report for the last 3 days so InputBox popup will be really good solution for me.

i will copy all source sheet name from the workbook to avoid mistakes

Availability LOG
"Events"
"IEC Communication"
"UNIT 1"
"UNIT 2"
"PTW"
"Operator round"
"Faults"
"Forced values"
"Out of reserve"

the target sheet name is:

"Report"


if the VBA code will copy the name of the source sheet to the target sheet before he copy the rows with the relevant date it will be great
i neet the final report to be Printable so headlines with the name of the source sheets will make it more readable
 
Upvote 0
You now say:
if the VBA code will copy the name of the source sheet to the target sheet before he copy the rows with the relevant date it will be great

Copy it where exactly you must always give specifics.
And now your asking for a Inputbox
What do you plan to enter into the Inputbox ?

And then weekends so if the script is run on what date does the script need to look for 3 dates.

I think:

This is beyond my knowledgebase.
I will continue to monitor this thread to see what I can learn.
 
Upvote 0
I hope someone will help me on this one :(
You said:
i have 10 source worksheets

So does this mean all the sheets in your workbook
Or must the script just look at certain sheets?
And the results will be put in a sheet named "Report Sheet"
 
Upvote 0
You said:
i have 10 source worksheets

So does this mean all the sheets in your workbook
Or must the script just look at certain sheets?
And the results will be put in a sheet named "Report Sheet"
yes all source sheets are in the same workbook
and all the results will go to target sheet name :"Report"
 
Upvote 0
yes all source sheets are in the same workbook
and all the results will go to target sheet name :"Report"
Yes I know all the sheets are in the same workbook.
What I need to know is do I have to tell the script each sheet name or can I just tell the script to look at all sheets. It's a lot easier to tell code to look at all sheets then to have to write out 10 different sheet names.
 
Upvote 0
yes i will have to tell the script each sheet name because i have some sheets that not include on the report sheet

Still hoping for some help with this......
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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