Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Jdoggers (TechnicalUser) (OP)
27 Jul 05 17:30
I used a variant to copy a whole range of cells and store them. I was wondering if there was any way to redimension or convert it into an array of doubles. Example:

dim myvariant as variant
dim convertedarray() as double

myvariant = range("A1:D10").value

'this is where i would like to convert it into an array of doubles

'something like
convertedarray = cdbl(myvariant)

'or maybe
convertedarray = split(myvariant)

'or perhaps

x = 0

for each myelement in myvariant
     convertedarray(x) = cdbl(myelement)


i have used similar approaches to these but none work. Any ideas or maybe something similar as something that i already tried to do?

Helpful Member!  TonyJollans (Programmer)
27 Jul 05 18:45
Hi Jdoggers,

You can't change the (primary) datatype of a variable so your myvariant will always be a variant. You can if you want  redimension an array of doubles to be the same size as the array in myvariant and then move each element separately. Do note, however, that ranges (and thus your variant) are two-dimensional. Is there a particular reason for wanting to do this?


We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress

Jdoggers (TechnicalUser) (OP)
27 Jul 05 19:41
well there are some reasons. First, im trying to get around the fact that it takes lots of time to access each cell one cell at a time. That is why i copied the range to a variant. The reason that i want to convert them to doubles is so that i can perform operations on them like a normal array, since you cant perform operations on a variant in that manner. Thanks
TonyJollans (Programmer)
27 Jul 05 19:49

I'm not sure what operations you can't perform but, when that's the case, you can use, say, Cdbl(myvariant(3,1)) instead of just myvariant(3,1). My guess is that would be quicker than moving all the individual elements one by one but it might depend on exactly what you were doing


We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close