Copy value not the formula

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,726
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I am using the code at present shown below.

The pasted value is £0.00 & in the address bar i see =SUM(C30:D30) which is from the cell that was copied on the original sheet.
I tried .PasteSpecial but that kicked up the Run time error 13 type mismatch,strange as when i debug it im shown something that isnt to do with the cell in question.



Code:
Private Sub CommandButton2_Click()    Dim Answer As Long
    Answer = MsgBox("Transfer Values To Summary Sheet ?", vbYesNo + vbInformation, "End Of Month Accounts")
    If Answer = vbYes Then
        Workbooks("ACCOUNTS").Sheets("INCOME1").Range("E32").Copy _
        Destination:=Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E49").PasteSpecial
        Workbooks("ACCOUNTS").Sheets("INCOME1").Range("F32").Copy _
        Destination:=Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E50").PasteSpecial
        ActiveWorkbook.Save
    End If
    
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Remove the line continuation characters after each Copy method name, remove the Distination:= argument names and add xlPasteValues at the end of the PasteSpecial property names.
Code:
[table="width: 500"]
[tr]
	[td]Private Sub CommandButton2_Click()
    Dim Answer As Long
    Answer = MsgBox("Transfer Values To Summary Sheet ?", vbYesNo + vbInformation, "End Of Month Accounts")
    If Answer = vbYes Then
        Workbooks("ACCOUNTS").Sheets("INCOME1").Range("E32").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E49").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("INCOME1").Range("F32").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E50").PasteSpecial xlPasteValues
        ActiveWorkbook.Save
    End If
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Sorry but could you advise the code as im finding hard to decipher that.
 
Upvote 0
OK sorry.
That goes to show my brain power isnt much.

I have now added it & works fine.
 
Upvote 0
Hi,
Can the below be simplified please ?

Code:
Private Sub CommandButton2_Click()    Dim Answer As Long
    Answer = MsgBox("Transfer Values To Summary Sheet ?", vbYesNo + vbInformation, "End Of Month Accounts")
    If Answer = vbYes Then
        Workbooks("ACCOUNTS").Sheets("EXPENSES1").Range("D30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E51").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("EXPENSES1").Range("F30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E52").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("EXPENSES1").Range("G30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E53").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("EXPENSES1").Range("H30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E54").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("EXPENSES1").Range("I30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E55").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("EXPENSES").Range("J30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E56").PasteSpecial xlPasteValues
        Workbooks("ACCOUNTS").Sheets("EXPENSES1").Range("K30").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E57").PasteSpecial xlPasteValues
        ActiveWorkbook.Save
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,704
Messages
6,173,984
Members
452,540
Latest member
haasro02

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