Hi!
I'm rather new to the forum and have been searching all over the place for some VBA code proposal I could apply to my problem.
Sadly I'm very inexperienced still (began learning on my own some weeks ago) and therefore haven't gotten a lot further.
The big list of data I work with in sheet 1 is as follows:
Sales contracts in A:A
Product in B:B
The number of products booked per Sales contract in cell A in C:C
A valid start date in D:D
A valid end date in E:E
The number of months validity in F:F (which I calculate myself based on C and D's input by means of formula)
What I'm looking for in the VBA code:
to allow me to paste data in sheet1 according to the structure above and accordingly will create in sheet2 a table per contract and product with
- a column for each month of the date range per contract, e.g. C1= 01.07.2016 and D1= 30.09.2016 so July 2016, August 2016 and September 2016
- divide the number of products on that contract equally over each month
- months outside of the range of course should not show any value
- needs to allow year changeovers
- preferably ran after a click on a button
We have made a file with excel formula but it's not pretty (plus sensitive info), so hence my post here
I've made a layout example in excel (example below).
Any help is much appreciated, of course I will continue to study my file improvements but a start would be great!
Sheet 1
[TABLE="width: 500"]
<tbody>[TR]
[TD]Contract[/TD]
[TD]Product[/TD]
[TD]Nr products[/TD]
[TD]Valid start[/TD]
[TD]Valid end[/TD]
[TD]Nr of months[/TD]
[/TR]
[TR]
[TD]201601[/TD]
[TD]x[/TD]
[TD]3[/TD]
[TD]01.07.2016[/TD]
[TD]30.09.2016[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]201602[/TD]
[TD]y[/TD]
[TD]16[/TD]
[TD]01.04.2015[/TD]
[TD]31.08.2016[/TD]
[TD]17[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2
[TABLE="width: 500"]
<tbody>[TR]
[TD]Contract[/TD]
[TD]Product[/TD]
[TD][/TD]
[TD]Apr 15[/TD]
[TD]May 15[/TD]
[TD]Jun 15[/TD]
[TD]Jul 15[/TD]
[TD]Aug 15[/TD]
[TD]Sep 15[/TD]
[TD]Okt 15[/TD]
[TD]Nov 15[/TD]
[TD]Dec 15[/TD]
[TD]Jan 16[/TD]
[TD]Feb 16[/TD]
[TD]Mar 16[/TD]
[TD]Apr 16[/TD]
[TD]May 16[/TD]
[TD]Jun 16[/TD]
[TD]Jul 16[/TD]
[TD]Aug 16[/TD]
[TD]Sep 16[/TD]
[/TR]
[TR]
[TD]201601[/TD]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]201602[/TD]
[TD]y[/TD]
[TD][/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I'm rather new to the forum and have been searching all over the place for some VBA code proposal I could apply to my problem.
Sadly I'm very inexperienced still (began learning on my own some weeks ago) and therefore haven't gotten a lot further.
The big list of data I work with in sheet 1 is as follows:
Sales contracts in A:A
Product in B:B
The number of products booked per Sales contract in cell A in C:C
A valid start date in D:D
A valid end date in E:E
The number of months validity in F:F (which I calculate myself based on C and D's input by means of formula)
What I'm looking for in the VBA code:
to allow me to paste data in sheet1 according to the structure above and accordingly will create in sheet2 a table per contract and product with
- a column for each month of the date range per contract, e.g. C1= 01.07.2016 and D1= 30.09.2016 so July 2016, August 2016 and September 2016
- divide the number of products on that contract equally over each month
- months outside of the range of course should not show any value
- needs to allow year changeovers
- preferably ran after a click on a button
We have made a file with excel formula but it's not pretty (plus sensitive info), so hence my post here
I've made a layout example in excel (example below).
Any help is much appreciated, of course I will continue to study my file improvements but a start would be great!
Sheet 1
[TABLE="width: 500"]
<tbody>[TR]
[TD]Contract[/TD]
[TD]Product[/TD]
[TD]Nr products[/TD]
[TD]Valid start[/TD]
[TD]Valid end[/TD]
[TD]Nr of months[/TD]
[/TR]
[TR]
[TD]201601[/TD]
[TD]x[/TD]
[TD]3[/TD]
[TD]01.07.2016[/TD]
[TD]30.09.2016[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]201602[/TD]
[TD]y[/TD]
[TD]16[/TD]
[TD]01.04.2015[/TD]
[TD]31.08.2016[/TD]
[TD]17[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2
[TABLE="width: 500"]
<tbody>[TR]
[TD]Contract[/TD]
[TD]Product[/TD]
[TD][/TD]
[TD]Apr 15[/TD]
[TD]May 15[/TD]
[TD]Jun 15[/TD]
[TD]Jul 15[/TD]
[TD]Aug 15[/TD]
[TD]Sep 15[/TD]
[TD]Okt 15[/TD]
[TD]Nov 15[/TD]
[TD]Dec 15[/TD]
[TD]Jan 16[/TD]
[TD]Feb 16[/TD]
[TD]Mar 16[/TD]
[TD]Apr 16[/TD]
[TD]May 16[/TD]
[TD]Jun 16[/TD]
[TD]Jul 16[/TD]
[TD]Aug 16[/TD]
[TD]Sep 16[/TD]
[/TR]
[TR]
[TD]201601[/TD]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]201602[/TD]
[TD]y[/TD]
[TD][/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD]0.941[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]