Copy Paste Range based on Column Header Match

marillionnut

New Member
Joined
Feb 28, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi, I've trying to solve a problem of copying data from one sheet to another based on the column header dates matching. The workbook is used to collect data over a week (sheet1) so as to produce weekly/monthly/annual data for a weekly report. At the start of each week the correct date is selected in sheet1 D3 and this changes the header dates Sheet1 D9:K9 and also feeds into the report and resulting charts etc (I am in the Middle East, so start of the week is Sunday...)

To make life easier for the team using the workbook all I need is for them to record the data over a week and then using a macro via a button, move that data into the corresponding dated columns in sheet2. When using simple offset code, it doesn't prevent the data being entered into the wrong dates, ie there is no check on matching headers - I need it only to go into the dates shown in sheet1 D9:K9

Many thanks,

Martin
Book1.xlsm
ABCDEFGHIJKL
1Select Week Start Date
2Week NoSundaySaturdayYearDate of First Whole Week
3Week Starting17-Jan-21317 Jan23 Jan 21202103-Jan-21
4
5 Daily Log - for use throughout the week
6
7
8
9Sat 16 JanSun 17 JanMon 18 JanTue 19 JanWed 20 JanThu 21 JanFri 22 JanSat 23 JanTotals
10HSEIncident LTI0
11Incident Non -LTI0
12Near Miss0
13IncidentsFire0
14HAZMATS0
15Rescue from Height0
16Rescue Confined Space0
17Road Traffic Collison0
18AFD False Alarm0
19Medical/Joint0
20Special Service Call0
21Standby Duties0
22Other0
Sheet1
Cell Formulas
RangeFormula
G3G3=WEEKNUM(D3,2)
H3H3=MAX(DATE(J3,1,1),DATE(J3,1,7)-WEEKDAY(DATE(J3,1,1),2)+(G3-1)*7+1)
I3I3=MIN(DATE(J3+1,1,0),DATE(J3,1,7)-WEEKDAY(DATE(J3,1,1),2)+G3*7)
J3J3=YEAR(K3)
D9D9=H3-1
E9E9=H3
F9:K9F9=E9+1
L10:L22L10=SUM(D10:K10)
Cells with Data Validation
CellAllowCriteria
D3List=List!$A$1:$A$52


Cell Formulas
RangeFormula
D1:BB1D1=C1+1
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Martin, did you have any luck with this? Looking to do something very similar myself, but struggling to find due to 1. How to explain it as well as you did or 2. how to search for it efficiently. Been trying for days!! Hoping you had some luck. Mine is similar in the sense we drop in a bunch of data into one sheet, then I want it to spit out the data for that day into a daily numbers table on another sheet. Want the macro button to do it to stop someone breaking the spreadsheet.
 
Upvote 0
Martin, did you have any luck with this? Looking to do something very similar myself, but struggling to find due to 1. How to explain it as well as you did or 2. how to search for it efficiently. Been trying for days!! Hoping you had some luck. Mine is similar in the sense we drop in a bunch of data into one sheet, then I want it to spit out the data for that day into a daily numbers table on another sheet. Want the macro button to do it to stop someone breaking the spreadsheet.
Hi, apologies for the delay in reply - haven't had a need to log onto the site for a while. I had some great help from a member (@Carim) on OzGrid and worked a treat.

 
Upvote 0
Solution

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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