Copy Paste code not working correctly

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I am using the code below but not getting a true copy / paste value etc.

The worksheet called MILEAGE at cell C32 has the formula =DOLLAR(D31*0.45) & currently shows £1.80
When i press the button the £1.80 is copied to cell reference E58 on the SUMMARY sheet but there is a mark in the cells top left corner.

The calculation then on the SUMMARY sheet is incorrect because of this mark or the way it was copied over even though paste special is used.

I mean if i delete the £1.80 from cell E58 & then manually type it in the calculation on the sheet is correct and no mark in the top left of cell.
If i then delete the £1.80 value in the cell & go back to the sheet MILEAGE & press the button the £1.80 is then put back into the cell E58,the mark is shown again & the calculation is wrong.



Code:
Private Sub CommandButton1_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("MILEAGE").Range("C32").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E58").PasteSpecial xlPasteValues
        ActiveWorkbook.Save
    End If
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Like this you mean ?

Code:
Private Sub CommandButton1_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("MILEAGE").Range("C32").Copy
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E58").PasteSpecial xlPasteValues
        Workbooks("SUMMARY 2018 - 2019").Sheets("Sheet1").Range("E58").NumberFormat = "$#,##0.00"
        ActiveWorkbook.Save
    End If
End Sub

I tried but still the same
 
Upvote 0
Forget the last post.

=DOLLAR(D31*0.45)
is now
=SUM(D31*0.45)
 
Upvote 0
No you are already converting it to text in the Dollar formula, if you use it then it will be text not a number.

Format both the cells as accountancy (use Round or Trunc if you need less decimal places before the format).

Edit: I see you have just amended your formula so all good :biggrin:

Not sure why you need the Sum part though as you could just do
=D31*0.45
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,750
Messages
6,180,740
Members
452,996
Latest member
nelsonsix66

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