VBA Force Paste Special Values Only

ThePianoman

New Member
Joined
Mar 15, 2011
Messages
15
Hi all, having some trouble with something that is likely very uncomplicated, but due to my very, very rookie status when it comes to VBA, it's complicated. I have a template being used for data import into a website tool developed for my team at work. It needs to be imported as a CSV file. I have a button to export the file to CSV, which is working fine.

Users will very likely be copying/pasting data from other workbooks into this template, and I need a VBA function that:
  • Force paste special, values only
  • Retains the ability to use undo function (ctrl+z)
  • No specific range(s). Anything that is copied and pasted into the workbook
  • Limited to the template only, macro doesn't run in other open workbooks

I've scoured multiple threads on this, nothing fit with what I need, and I am not nearly experienced enough to compile code from multiple sources to fit my needs. Jaafar Tribak's solution in this thread worked to some extend, but the macro was running in all workbooks I had open and errors were occurring.

Can someone provide VBA code for this, with a semi-detailed explanation of where to put it in the editor (worksheet vs workbook vs module), and how it works? I would be so appreciative.

Thank you.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,772
Messages
6,126,811
Members
449,339
Latest member
Cap N

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