Forum Discussion
Locky81
Aug 22, 2022Copper Contributor
Result from macro copy and paste error
Hi Team, I have a value in a cell that I'm trying to simply copy and paste (as value only), that I've programmed into a simple macro. When this value is the product of a formula the macro driven ...
- Aug 22, 2022
Locky81 Understood your problem. Actually you are pasting twice. So you do not need second ActiveSheet.Paste line. Delete it from your code. I have comment it in my below codes.
Sub EXECUTECOPYPASTE() Range("K5").Select Selection.Copy Range("L15").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False 'ActiveSheet.Paste Application.CutCopyMode = False End SubBasically you can do it by below single line code.
Sub CopyValue() Range("L15").Value = Range("K5").Value2 End Sub
Locky81
Aug 22, 2022Copper Contributor
Sub EXECUTECOPYPASTE()
'
' EXECUTECOPYPASTE Macro
'
'
Range("K5").Select
Selection.Copy
Range("L15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
Harun24HR
Aug 22, 2022Bronze Contributor
The codes looks pretty good. What problem you are facing with this code?
- Locky81Aug 22, 2022Copper ContributorActually I just checked, it is succesffully copying the Formula itself (meaning the number generates from the formula) I need it to copy and paste the raw value (result) FROM the formula only. so it's copying my formula =IF(L14=TRUE,$J$6,0) instead of the value/result of the formula, which is for eg. 31076.85
- Locky81Aug 22, 2022Copper ContributorYea mate, my Macro 'works'. The copy and paste executes succesffully (when I hit 'run' on the Macro screen). It will however ONLY seem to work if my number is sitting in the cell as a plain value. If the same number is placed in that cell as a result of a Formula - it will not copy and paste. I've set my Macro to paste as 'values' only. Is that correct??