desibabuji
New Member
- Joined
- Dec 31, 2012
- Messages
- 4
Hello,
I have a worksheet that has some data that is a copy and paste from 2 different sheets. We calculate the percentage complete and then manually calculate the differences. I need some help in creating a macro to automate this process. Can someone please help.
Attached is a sample worksheet with "Sample" as the worksheet with the data and "Result" is what I am trying to achieve.
I want to be able to find the first blank cell in column E and then calculate the average of all the digits before the next blank cell is found and so on.
The rows between the blanks will vary based on the month and the week the report is run but will always have a blank cell before the data for the next person. The format will remain the same though.
Then, as per the results worksheet.
1. Insert 3 columns for Target % (E), Distribution % (F) and the Difference in % (G).
2. Calculate the average percentage for Distribution in Column (H).
3. Values in Column F are essentially copy of calculated values from column (H).
4. Column E is the % complete using the formula for Column (D) and (E).
5. And finally column G is the difference between column (E) and (F).
This is what I have so far
<code>
</code>
Someone at the other forum suggested to use a formula instead and copy past the formula all the way in the row but I want to automate the process and not having to manually enter, paste and drag the formula everytime, as the number of rows can vary from 20 to upto 5000.
Here's a sample file https://www.box.com/s/fnyri3xdq863t75f3e8o
I really appreciate your help.
I have a worksheet that has some data that is a copy and paste from 2 different sheets. We calculate the percentage complete and then manually calculate the differences. I need some help in creating a macro to automate this process. Can someone please help.
Attached is a sample worksheet with "Sample" as the worksheet with the data and "Result" is what I am trying to achieve.
I want to be able to find the first blank cell in column E and then calculate the average of all the digits before the next blank cell is found and so on.
The rows between the blanks will vary based on the month and the week the report is run but will always have a blank cell before the data for the next person. The format will remain the same though.
Then, as per the results worksheet.
1. Insert 3 columns for Target % (E), Distribution % (F) and the Difference in % (G).
2. Calculate the average percentage for Distribution in Column (H).
3. Values in Column F are essentially copy of calculated values from column (H).
4. Column E is the % complete using the formula for Column (D) and (E).
5. And finally column G is the difference between column (E) and (F).
This is what I have so far
<code>
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit;">Sub average_empty_cells() Dim myAreas As Areas, myArea As Range On Error Resume Next Set myAreas = Range("e2", Range("e" & Rows.Count) _ .End(xlUp)).SpecialCells(2, 1).Areas On Error GoTo 0 If myAreas Is Nothing Then Exit Sub For Each myArea In myAreas myArea(0).Formula = "=average(" & myArea.Address & ")" Next End Sub</code></pre>
Someone at the other forum suggested to use a formula instead and copy past the formula all the way in the row but I want to automate the process and not having to manually enter, paste and drag the formula everytime, as the number of rows can vary from 20 to upto 5000.
Here's a sample file https://www.box.com/s/fnyri3xdq863t75f3e8o
I really appreciate your help.