Link to home
Start Free TrialLog in
Avatar of mnoisette
mnoisetteFlag for United States of America

asked on

Copy data from one Excel sheet to another based on criteria VBA

I have a workbook with the months January through December.
At the end of each month, if the patient has not been released, I would like the line(s) of information to be copied to the following month.

Attached is a copy of a test workbook.
Hospital-Report-Test.xlsm
Avatar of redmondb
redmondb
Flag of Afghanistan image

Hi,

A few questions, please...
(1) How do know which month to process - simply use the month previous to the current date?
(2) When processing the December sheet do we really loop back to the "January" sheet or will you add the year to the sheet name? (If the latter then we could simply copy the previous month's sheet to create the new one (and drop the released patients.)
(3) Do you want anything done to the Summary sheet.?

Thanks,
Brian.
Avatar of mnoisette

ASKER

Brian,

Answers:

(1) If a patient does not have a release date entered, then, yes you can simply use the month previous to the current date...

(2) When December comes, you can just loop back to the January sheet. I think that would be easy for my boss.

(3) The Summary sheet only contains patients that have not been released. That one should be fine as is...

Thanks!
Maurice
Thanks, Maurice.

(1) If a patient does not have a release date entered, then, yes you can simply use the month previous to the current date...
I assume that whenever the macro is run it only process the data in one sheet. If that's correct then I need to know which sheet to use.

Thanks,
Brian.
Thanks Brian,

Use only the sheet to the left of the current month sheet.
I think thats the answer you may be looking for...

Mo
Perfect, thanks, Mo!

Now one more - the formulas in column D is circular. What isw it supposed to be?

Thanks,
Brian.
Brian,

I didn't create that one...
But it pulls the info into the Summary sheet if the "Actual Release Date" is blank. But it only works for January.

The concept is that if the patient has not been released from any of the months (January through December) the Summary sheet shows a list off all the patients for all the months.

Hope it makes sense....
Mo,

Edit:
Sorry, we're talking at cross purposes - I'm concerned about the circular references in column D of the detail sheets, i.e January to December. By all means, just give me an English explanation of what should be in those cells.

Edit2:
I'm assuming that any row with data on it will have a non-blank value in column A.

Regards,
Brian.
ASKER CERTIFIED SOLUTION
Avatar of redmondb
redmondb
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Brian,

Please keep in mind that usually when people ask for reports, they don't even know what they are asking for...LOL

The person asking for this report (not me) wants the Summary page to show patients that are still in the hospital and not released yet.
For example, if a ptient is admitted on Feb 25th, he may still be in the hospital come March 1st. The Summary sheet would show all these patients.

Please disregard that formula in column D. The person that started this workbook wasn't sure what to do. Delete it if you need to.

And, yes.... Column A would have a non-blank value for any row with data.

Thanks Brian
Thanks, Mo.

The person asking for this report (not me) wants the Summary page to show patients that are still in the hospital and not released yet.
And that's what it is doing - and for all months, not just January.  The reason you thought the other months weren't working is because they are way down the summary sheet. - click on the "UPDATE FILTER" button to make the report look sensible!

Please disregard that formula in column D. The person that started this workbook wasn't sure what to do. Delete it if you need to.
Done. And I've also updated each sheet's Heading to 2013, please see attached.

Regards,
Brian.
Hospital-Report-Test---V3.xlsm
Thanks, Mo.