#### dawsona

##### Board Regular
I have an existing project report that has two lines per project - revenue and cost.

My boss wants a more detailed report which means that each project now has five lines of analysis.

The problem is that the existing report is wo be used as a summary. There are potentially 100 projects and I need a macro that will reference from the summary back to the detail.

I need a loop that starting at row 1 it will put in a formula in B1 that equals the sum of ("B1:B2") on the detail sheet then B2 will equal B5 on the detail sheet.

I will then use the offset command to move to the next row but am struggling to get it to pick up the data from the correct rows 7:9 and 12 in the first instance.

This needs to be done by way of formulas linking to the other sheet rather than pivot tables or similar solutions.

Any suggestions?

### Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
This seems to work:

Code:
``````Sub Test()
Const Incr As Integer = 7
Dim DetSh As Worksheet
Dim DetRng As Range
Dim SumSh As Worksheet
Dim c As Range
Dim Formula1 As String
Dim Formula2 As String
Dim x As Long
Dim y As Long
Dim z As Long
Set DetSh = Worksheets("Detail")
Set DetRng = DetSh.Range("B1:B" & DetSh.Range("B65536").End(xlUp).Row)
Set SumSh = Worksheets("Summary")
x = 1
y = 5
z = 1
Do
Formula1 = "=SUM(Detail!B" & x & ":B" & x + 1 & ")"
Formula2 = "=Detail!B" & y
SumSh.Cells(z, 2).Formula = Formula1
SumSh.Cells(z + 1, 2).Formula = Formula2
x = x + Incr
y = y + Incr
z = z + 2
Loop While z <= (DetRng.Rows.Count / Incr * 2)
End Sub``````

Andrew

I have only just manged to find time to try out the code and it really is the "dog's whatsits!"

The example I gave wasn't quite true in terms of ranges but I can understand the code enough to manipulate to what I want.

Thanks again.

Replies
1
Views
230
Replies
0
Views
252
Replies
1
Views
116
Replies
0
Views
128
Replies
1
Views
350

1,203,521
Messages
6,055,883
Members
444,830
Latest member

### 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.

### Which adblocker are you using?

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

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