Please Help Make This Paste Special

rockyw

Well-known Member
Joined
Dec 26, 2010
Messages
1,196
Office Version
  1. 2010
Platform
  1. Windows
This code works well but I need it to paste special. Can you help me with this? Thanks

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("P:P,B:B")) Is Nothing Then
        With ThisWorkbook
            .Sheets("Sheet2").Range("E3:E24").Value = .Sheets("Sheet3").Range("E3:E24").Value
        End With
    End If
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This should be the equivalent of what you posted using PasteSpecial. I'm guessing you will want to change the argument to the PasteSpecial line from xlPasteValues to one of the other available arguments (you didn't say which)...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("P:P,B:B")) Is Nothing Then
        With ThisWorkbook
            .Sheets("Sheet3").Range("E3:E24").Copy
            .Sheets("Sheet2").Range("E3:E24").PasteSpecial xlPasteValues
        End With
    End If
End Sub
 
Upvote 0
Thank you, I want to paste values only, do I need to change anythng for that. The one blank cell returned a 0, can this code be made to not returna 0 from an empty cell? Thanks
 
Upvote 0
Thank you, I want to paste values only, do I need to change anythng for that. The one blank cell returned a 0, can this code be made to not returna 0 from an empty cell? Thanks
No, for values only, the code I posted is all you need; but I don't understand why you asked to change your original code... direct assignment of values is faster than using Copy/Paste Special (although for only two cells, you won't ever see the difference in speed). As for your question about 0... I don't get that happening on my system... blank cells copy over as blank cells.
 
Upvote 0
The blanks have a formula but no value, is that why it returns a 0? Can we stop that. That was the problem with the other code.
 
Upvote 0
The blanks have a formula but no value, is that why it returns a 0? Can we stop that. That was the problem with the other code.
If the formula is returning the empty string (""), then it shouldn't convert to 0 when copied (at least it did not do it when I just tested it).
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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