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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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,215,034
Messages
6,122,782
Members
449,095
Latest member
m_smith_solihull

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