Build Paste Special Value Function

GeoKoro13

New Member
Joined
Nov 24, 2016
Messages
27
Hi there,

I'm new here and just recently try to use VBA to make my life a bit easier. But still I'm away in making a code by myself.

What I'm trying to do at the moment is to build a function to copy-paste special the value only. I've seen people posting how to copy and paste special from specific cells, but it would make my job much easier if I could just typing =pastespecial(...).

Any idea if that could happened?

Regards
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Do you mean typing .PasteSpecial into VBA?

the syntax is like this

.PasteSpecial(Paste, Operation, SkipBlanks, Transpose)

for the first part, Paste, you can choose any of the following
xlPasteAllEverything will be pasted.
xlPasteAllExceptBordersEverything except borders will be pasted.
xlPasteAllMergingConditionalFormatsEverything will be pasted and conditional formats will be merged.
xlPasteAllUsingSourceThemeEverything will be pasted using the source theme.
xlPasteColumnWidthsCopied column width is pasted.
xlPasteCommentsComments are pasted.
xlPasteFormatsCopied source format is pasted.
xlPasteFormulasFormulas are pasted.
xlPasteFormulasAndNumberFormatsFormulas and Number formats are pasted.
xlPasteValidationValidations are pasted.
xlPasteValuesValues are pasted.
xlPasteValuesAndNumberFormatsValues and Number formats are pasted.

<tbody>
</tbody>

for the second part, Operation, you can include these (provided that you are pasting numeric data and not a formula or a format or text)
xlPasteSpecialOperationAddCopied data will be added with the value in the destination cell.
xlPasteSpecialOperationDivideCopied data will be divided with the value in the destination cell.
xlPasteSpecialOperationMultiplyCopied data will be multiplied with the value in the destination cell.
xlPasteSpecialOperationNoneNo calculation will be done in the paste operation.
xlPasteSpecialOperationSubtractCopied data will be subtracted with the value in the destination cell.

<tbody>
</tbody>
Leave this blank if you do not want an operation performed.

SkipBlanks, and Transpose are True or False values. If left blank they will by default be false, but if you would like blanks skipped, or for the data to be transposed, set the appropriate one to True




 
Last edited:
Upvote 0
User defined functions can only return values to the cell(s) they are in.

They can't be used to put/change values in other cells which is what you appear to want to do.
 
Upvote 0
Welcome to the forum!

User Defined Functions (UDFs) return values and not perform what Subs can do.

You could use a Worksheet event and enter some value to cause the action. It would be better to just add a hot key combination to a Sub that acts on the activecell to do it.
 
Upvote 0
Thank you for the quick response.

Well, I mean building a formula that can be used in a spreadsheet that will paste the value from another cell.
So, for instance I will type in a cell ="function name"(A1) and will permanently paste the value. The problem is that I don't want to have a specified range of cells to paste their values but instead I would like to use a custom formula that will do that for me.

Does that make sense?
 
Upvote 0
So, it's not possible to use a UDF to call a macro that will paste special a value for the cell I'm interested for?
 
Upvote 0
What kind of paste special are you looking to do? Perhaps your goal can be achieved via another method (different formulas for example or the format painter...)
 
Upvote 0
Why would a dynamic Macro not work for you. Explain a little more and give an example of what your wanting to do.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,462
Members
448,965
Latest member
grijken

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