macro - copy values only

J

JQ

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
 
T

Tom Ogilvy

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
 
Top