VBA to sum

michelcr7

New Member
Joined
Jun 14, 2018
Messages
7
Hi Guys,

I have 10 product, in value C3 when I put 1, macro caluclate & copy/paste some values for product 1, when put 2 in C3 macro calculate & copy/paste some values for product 1 and for product 2, when 1 put 3 in C3 macro calculate & copy/paste some values for product 1 and for product 2 and product. In another sheet "DCF Quarterly" i have some values for calculation. When choose 1 in C3 values appear for product 1, when I put 2 in C4 values appears for product 2. Is it possible sum up those values? For example:
I choose 3 in C3, then in "DCF Quarterly" macro caluclate & copy/paste some values for product 1&2&3, but each time during the calcuatlion some values appear for product 1 , then they are replaced by 2 & replace by product 3.s it possible sum up those values for 1&2&3 and present somewhere in "DCF Quarterly" sheet.




Code:
Sub RunTests()'
' RunTests Macro
'
    Sheets("Portfolio Overview").Select
    
    Dim i As Integer
    Dim ifrom, ito As Integer
    
    ifrom = Range("C2").Value
    ito = Range("C3").Value
    
    For i = ifrom To ito
        Sheets("DCF Quarterly").Select
        Range("B4") = i
        Range("R9:R18").Select
        'Application.CutCopyMode = False
        Selection.Copy
        Sheets("Portfolio Overview").Select
        Cells(11 + i - ifrom, 2).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=True
        Cells(11 + i - ifrom, 1).Value = i
    Next i
    
End Sub
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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