Jillian
Jillian

Reputation: 3

Copy sums from one Excel file to another

I have one file (Book 1) with a column of numbers and a formula to sum them up. I need to copy that sum from Book 1 to a cell in Book 2, Book 3, etc. I end up copying the formula and moving it, not the sum itself.

Sub CopyInfo()
    experiment1.Range("F7").Value = experiment2.Range("I5").Value
    experiment1.Range("F7").Copy
    experiment2.Range("I5").Paste
    Application.CutCopyMode = False
End Sub

I'm trying to copy from "experiment1" to "experiment2".

Upvotes: 0

Views: 1845

Answers (2)

Jon49
Jon49

Reputation: 4606

Do a past special, so you would have:

dim wkb1 as workbook, wkb2 as workbook
Dim r1 as range, r2 as range

set wkb1=workbooks("wkb1")
set wkb2=workbooks("wkb2")
set r1=wkb1.worksheets("whatever").range("A1")
set r2=wkb2.worksheets("whatever2").range("A1")
r1.copy
r2.PasteSpecial xlPasteValues

Upvotes: 0

lnafziger
lnafziger

Reputation: 25740

Instead of Paste, use PasteSpecial like this:

experiment2.Range("I5").PasteSpecial xlPasteValues

This will paste the calculated value instead of the formula.

Upvotes: 2

Related Questions