ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Want to use a Macro to copy and paste cell *value* only (https://www.excelbanter.com/excel-discussion-misc-queries/142471-want-use-macro-copy-paste-cell-%2Avalue%2A-only.html)

HeadRusch

Want to use a Macro to copy and paste cell *value* only
 
Hello,

My simple macro is as follows:

If IsEmpty(Range("B17")) Then
Range("E2").Copy Destination:=Range("B17")
Else
Range("E2").Copy Destination:=Range("B65535").End(xlUp).Offset(1, 0)
End If

This works great except for one problem, Cell E2 is a calculation cell.
When I paste the value I get errors. What I want to paste is ONLY the value
of the cell, not the formula behind it, but I cannot figure out the syntax of
how to do that with the Copy Destination operators.

Can anyone assist? Thank You!

JLatham

Want to use a Macro to copy and paste cell *value* only
 
Try
If IsEmpty(Range("B17")) Then
Range("B17").Value = Range("E2").Value
Else
'next is all one statement

Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("E2").Value

'end of the single statement
End If

"HeadRusch" wrote:

Hello,

My simple macro is as follows:

If IsEmpty(Range("B17")) Then
Range("E2").Copy Destination:=Range("B17")
Else
Range("E2").Copy Destination:=Range("B65535").End(xlUp).Offset(1, 0)
End If

This works great except for one problem, Cell E2 is a calculation cell.
When I paste the value I get errors. What I want to paste is ONLY the value
of the cell, not the formula behind it, but I cannot figure out the syntax of
how to do that with the Copy Destination operators.

Can anyone assist? Thank You!



All times are GMT +1. The time now is 12:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com