VBA assistance for conditional copy and paste

Peter Muller

Board Regular
Joined
Oct 15, 2018
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hello VBA Experts,

I really do need your help!

I realise that my thread title did not indicate that I require VBA assistance, hence my re-post from Sun 3rd, with a new thread title.


Hello Experts,

I please need your assistance again. I have a problem, and have absolutely no idea how to go about resolving it. Please help.
  • Each task in the "Task_Table" is either required on a specific day (Mon-Fri), or every day.
  • When I activate the macro, today's day / the current day is used to identify which tasks must be copied and pasted in the input document which is linked to the pivot, with the daily tasks also copied from the 'Task_Table and pasted into the same input document.
  • If there are 10 daily tasks, and 5 for a Mon, then running the macro and selecting "Mon", 15 tasks must be copied from the Tasks_Table and pasted into the input doc, and if 3 tasks on a Tue, then 13 tasks to be pasted into the input doc when "Tue" is selected.
  • Each Day's tasks must be pasted below the last task of the 'previous day'.
  • The input doc is in columns B:M, and the copied info is to be pasted into col D. The cell address where I select the relevant day for the macro is in "O2"

Task_TableInput doc linked to Pivot - Columns B-M
TaskFrequencyDescription 'Column D'Mon
ReconcilliationDailyReconcilliation
Replenish cashWedAge Analysis - A-F
Age Analysis - A-FMonBank Recons
Age Analysis - G-LTueUpdated Skills Matrix
Age Analysis - M-QWedTNA, submitted
Age Analysis - R-ZThuT scheduled & Monitored
Supplier Recons - A-FTueRegisters monitored
Supplier Recons - G-LWedLate & Absent actioned
Supplier Recons - M-QThu
Supplier Recons - R-ZFri
Bank ReconsDaily
Updated Skills MatrixDaily
TNA, submittedMon
T scheduled & MonitoredDaily
Registers monitoredDaily
Late & Absent actionedDaily
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
This is not difficult to do, Peter, but I want to clarify a few things before I set to code it:
  1. You say the input is in columns B:M. That is 12 columns. Your example only shows 2 columns.
  2. Column D is in this range B:M, how is that?
  3. When is the macro run? Always on today's dat or sometimes in advance (in preparation for tomorrow for instance)?
  4. The list is to be copied below the last task of previous day. Does the user remove the items he has completed? Do you want to compact the list to remove any blank lines?

Please answer these
 
Upvote 0
This is not difficult to do, Peter, but I want to clarify a few things before I set to code it:
  1. You say the input is in columns B:M. That is 12 columns. Your example only shows 2 columns.
  2. Column D is in this range B:M, how is that?
  3. When is the macro run? Always on today's dat or sometimes in advance (in preparation for tomorrow for instance)?
  4. The list is to be copied below the last task of previous day. Does the user remove the items he has completed? Do you want to compact the list to remove any blank lines?

Please answer these

Good evening,

Thank you so much for assisting me.

Column D is the ‘lookup value’; hence, all the other columns are dependent on it. Example, Col B is the ‘Project Name”, which is looked up in/from a separate table based on Col D, and Col C is the category looked up from another table, also dependent on Col D, etc.

The info to be copied and pasted into Col D can be placed in the 1st col of the range, i.e., Col B, with the intended Columns B & C moved to the right (to C & D) – my only reason is aesthetics, and for logical flow.

Ideally, the macro is run at the start of day, Mon – Fri, but the day the macro uses to populate Col D, must be selected by the user typing the day in Col O2. Col O2 is formatted to ‘custom’ and ‘ddd’

The user does not remove the completed tasks, but only indicate with “Y” in Col F, if the task is completed.
 
Upvote 0
Is it possible for you to post a (sanitised if necessary) copy of the workbook in dropbox or similar? If difficult to sanitise, then you can let me know the location of the workbook in a private message. It will hel;p me understand better what you are trying to explain.
 
Upvote 0
Is it possible for you to post a (sanitised if necessary) copy of the workbook in dropbox or similar? If difficult to sanitise, then you can let me know the location of the workbook in a private message. It will hel;p me understand better what you are trying to explain.

ABCDEFGHI
1
2Tue
3ProjectCategoryDescriptionDateCompletedWeightingScoreProgress
4FinancePetty CashReconciliationTue 12/05Y55100%
5FinancePetty CashReplenish cashTue 12/05Y33100%
6

Macro from Info in 'I2' (deleted some of the columns, reducing the range) and Task Table

Col B & C is looked up from Task Table (below) based on the contents pasted into Col D

Col D is the results from the macro

Col E is the Date relating to Col D & I2

Col F is where the user enters "Y", otherwise it defaults to “N”

Col G - H is determined based on Col D, from Task Table

Col I calculated

PQRST
1Task Table
2
3TaskFrequencyWeightProjectCategory
4ReconcilliationDaily5FinancePetty Cash
5Replenish cashTue3FinancePetty Cash
6Age Analysis - A-FTue3FinanceDebtors
 
Upvote 0
OK, clear now. I'll see what I can do
 
Upvote 0
Another question: Say that daily task Reconciliation was not completed on Monday. When you run the macro on Tuesday, do you want to add a new line Reconciliation, or leave the one unfinished open with adding a new one? (else you would have two open tasks Reconciliation)
 
Upvote 0
Another question: Say that daily task Reconciliation was not completed on Monday. When you run the macro on Tuesday, do you want to add a new line Reconciliation, or leave the one unfinished open with adding a new one? (else you would have two open tasks Reconciliation)

I am unsure of exactly what you are asking, but the intention is that Mon’s tasks remain, reflecting the ‘results’ of the day , Tue is added below that, wed below Tue, etc.

The idea is to eventually graph the performance trend for the employee.
 
Upvote 0
OK. Another question:
You use the cell I2 for day input. Is that important, or could the macro just use the current date?
problem is that I2 is a day, without a date. Yet in column E you use the date.

  1. So I could use today's date, or use the next date following from the last date in the table (taking account of weekends).
  2. Or if you want to stick to I2, I can calculate the date checking if today or tomorrow is the Tue entered in I2.
which option do you want?
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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