Cycle through array - paste to next row in range

cortexnotion

Board Regular
Joined
Jan 22, 2020
Messages
150
Office Version
  1. 2013
Platform
  1. Windows
Hi there

My code is working well but I want to paste each Area output to the next row between B6:J6 down to B14:J14. However at the moment it is writing everything to row 6 and overwriting itself.

I can't figure out how to get the code to post to the next free row from B5:J5 downwards so it fills all 9 rows. Any help would be great!

Code:
With Sheets("Are")
LRb = .Range("B15").End(xlUp).Row + 1

For Each Area In Array("""AA""", """BB""", """CC""", """DD""", """EE""", """FF""", """GG""", """HH""", """II""")

.Range("B" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & FinCompPcRng & "))")
.Range("C" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & FinCompNoRng & "))")
.Range("D" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & FinCompValRng & "))")
.Range("E" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & TimeCompPcRng & "))")
.Range("F" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & TimeCompNoRng & "))")
.Range("G" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & TimeCompValRng & "))")
.Range("H" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & SubCompPcRng & "))")
.Range("I" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & SubCompNoRng & "))")
.Range("J" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & SubCompValRng & "))")
Next Area
End With




End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
No tested.

Try this

Rich (BB code):
LRb = .Range("B15").End(xlUp).Row + 1

For Each Area In Array("""AA""", """BB""", """CC""", """DD""", """EE""", """FF""", """GG""", """HH""", """II""")

.Range("B" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & FinCompPcRng & "))")
.Range("C" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & FinCompNoRng & "))")
.Range("D" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & FinCompValRng & "))")
.Range("E" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & TimeCompPcRng & "))")
.Range("F" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & TimeCompNoRng & "))")
.Range("G" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & TimeCompValRng & "))")
.Range("H" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & SubCompPcRng & "))")
.Range("I" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & SubCompNoRng & "))")
.Range("J" & LRb).Value = Application.Evaluate("SUMPRODUCT((" & WeekRng & "=" & LW & ")*(" & AreaRng & "=" & Area & ")*(" & SubCompValRng & "))")

LRb = LRb + 1

Next Area
End With
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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