How do I adjust VBA to copy from sheet 1 and paste results on sheet 2?

NHagedorn

New Member
Joined
May 11, 2012
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Not sure how to adjust code to copy from one sheet and paste results on another.


Sub loop4()
'with dynamic range
'dynamic Range (vertical only and horizontal)

'get last used Row
iLastUsedRow = Range("B3").End(xlDown).Row

dateCol = 3

For col = 9 To 12

For r = 3 To 5

'Cells(r,col).FormulaR1C1= "=SUMIFS(R3C3:R16C3, R3C2:R16C2, R3C" & col &")"

Cells(r, col).FormulaR1C1 = "=SUMIFS (R3C" & dateCol & ":R" & iLastUsedRow & "C" & dateCol & _
", R3C2:R" & iLastUsedRow & "C2,R" & r & "C8)"

Next r

dateCol = dateCol + 1

Next col

End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Not sure how to adjust code to copy from one sheet and paste results on another.

It's not clear how your question relates to the code you've posted ...

What do you want to copy, and where do you want to paste it?

By the way, you can put in your formula without looping through rows and columns:

Range("I3:L5").Formula = "=SUMIFS(C$3:C$" & iLastUsedRow & ",$B$3:$B$" & iLastUsedRow & ",$H3)"
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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