Hi,
I have a big problem to write a macro for the following:
What I have is 4 columns in worksheet 1:
A1: Contains a name
B1: Contains fromDate and time (formatted yyyy-mm-dd hh:mm)
C1: Contains toDate and time (formatted yyyy-mm-dd hh:mm)
D1: Contains a value
Now, the columns can have many rows with different names, dates and values - and what I want to do is to write a macro that does the following in worksheet 2:
Column A.
Put the name in column A on each row as many times as there are hours between B1 and C1 in worksheet 1.
Column B.
Autofill date and time based on B1 and C1 in worksheet 1.
Example:
2013-01-01 00:00
2013-01-01 01:00
2013-01-01 02:00
2013-01-01 03:00
2013-01-01 04:00
....
and so on down to the toDate and last hour for that row in worksheet 1.
Column C.
Autofill the divided value in D1 in worksheet 1. The value should be divided into the total amount of hours given in B1 and C1.
So if the date and time was between 2013-01-01 00:00 to 2013-01-01 04:00 and the total value was 400 in worksheet 1, the macro should put 100 in C1, C2, C3 and C4 in worksheet 2. The A column should have the name in A1, A2, A3 and A4 and the time and date should be presented as I show right over here.
I attach a sample file for how the workbook can look like. WS1 is the input sheet and WS2 is how the result should be shown when the macro is been record and started.
I hope somebody can help me with this. I would appreciate it very very much, and a big thank you in advance!! :-)
Br,
Macenmin
Bookmarks