Macro to Paste special any values into a worksheet

Milos

Board Regular
Joined
Aug 28, 2016
Messages
121
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Does anybody know how to design a macro that will paste special any values that I put into a worksheet (Sheet1)? My copied values will change in size and could be from multiple other spreadsheets. So the code probably needs to remember the last action performed rather than a spreadsheet name.

I had started working on some simple code for this but this is far beyond my noob capabilities..

Any help is greatly appreciated!

Thanks,
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Perhaps you could use a change event macro in each sheet module you want to copy the values from.

You would change Range("A1:Z10")) to suit the range on each sheet as necessary (the range you want to copy FROM).

The code here copies to Sheet1 to the next empty cell in column M.

Howard

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A1:Z10")) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    
     Target.Copy
     Sheets("Sheet1").Range("M" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
    
    Application.EnableEvents = True
    Application.CutCopyMode = False
    
End Sub
 
Upvote 0
Thanks. I was wanting to design a macro for the sheet that I will paste values into. This is what I have so far:

Sub Paste_Values_Any_Sheet ()

With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteColumn With
End With

End Sub

Macro only works if you attach it a command button to it though as clipboard deletes the copy for some reason.
 
Upvote 0
Okay, what or how do you determine what gets copied from a sheet and what determines which sheets are to be copied from.

Can you give a step by step procedure of how you want the macro to determine the sheet/s to copy from and how to determine what is to be copied from the sheet/s.

And where on the destination sheet is the data to be copied to.

Howard
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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