ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro - copy values only (https://www.excelbanter.com/excel-programming/304847-macro-copy-values-only.html)

JQ[_2_]

macro - copy values only
 
When I say x = Range("a1") I am copy all formatting as
well as the value in the cell. Is there a way to assign a
variable to the value in the cell only?
I want to be able to search a column and if certain
conditions are true I want to say something like
Range("X2") = x

Thanks


Tom Ogilvy

macro - copy values only
 
if use VBA,

Dim x as Variant
x = Range("A1").Value
Range("X2").Value = x

is just the value in the cell

if you did

Dim x as Range
set x = Range("A1")

then you have created a reference to the cell and you can deal with
formatting and so forth. even in this second instance you can do

Range("X2").Value = x.Value

--
Regards,
Tom Ogilvy


"JQ" wrote in message
...
When I say x = Range("a1") I am copy all formatting as
well as the value in the cell. Is there a way to assign a
variable to the value in the cell only?
I want to be able to search a column and if certain
conditions are true I want to say something like
Range("X2") = x

Thanks





All times are GMT +1. The time now is 02:10 PM.

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