Cycle through array - paste to next row in range

cortexnotion

Board Regular
Joined
Jan 22, 2020
Messages
138
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,620
Office Version
  1. 2007
Platform
  1. Windows
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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,620
Office Version
  1. 2007
Platform
  1. Windows
Im glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,674
Messages
5,637,729
Members
416,981
Latest member
PLonchar

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
Top