To fetch the values from the excel cells into the variable

  • Thread starter Thread starter chetana
  • Start date Start date
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
 
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
 
Is your Selection a single cell?

What did you "Dim" X2 as?

Do you have any errors in your Selection?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top