To fetch the values from the excel cells into the variable

C

chetana

Hello,

I have tried to extract the data from a range of cells into local
variable so that I can write the extracted data in the freefile using
VB code.
Can you kindly let me know what will be the correct code.

Below is the way I have tried, but assinging to variable always
results in type mismatch error.
X2 = StrConv(Selection.Value, vbUpperCase)

Thanks and Regards
Chetana
 
M

mangesh_yadav

the above code works perfectly fine for me. I tried

abc = StrConv(ActiveSheet.Range("A1").Value, vbUpperCase)
MsgBox (abc)

it prints XABC (Cell A1 has the string Xabc)

The only probelm you could have is the definition of your variable X2
Just say
Dim X2
or
Dim X2 as variant

you must have probably defined it as a number type like int or double
in which case you would get the type mismatch error in case the valu
is a string.

- Manges
 
J

JE McGimpsey

Is your Selection a single cell?

What did you "Dim" X2 as?

Do you have any errors in your Selection?
 
Top