Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What datatype holds this {1,2;3,4} ? (It's not a string far as I can tell.)

Posted on 2012-03-09
9
Medium Priority
?
377 Views
Last Modified: 2012-06-27
What datatype holds this {1,2;3,4}  Must it be variant?

The context is Evaluate(A1) where A1 contains this string {1,2;3,4}, which when evaluated is an array constant (I think).

I have experimented with various types, but they all get errors except Variant.

Anthony
Aspiring Novitiate, polishing my Datatypes
0
Comment
Question by:Anthony Mellor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 37703090
I think you can only use a string for that purpose.
0
 
LVL 50
ID: 37703102
Hello,

it's a two-dimensional array with two rows and two columns. The commas starts a new row, the semicolon starts a new column.

cheers, teylyn
0
 
LVL 17

Assisted Solution

by:andrewssd3
andrewssd3 earned 1000 total points
ID: 37703434
As teylyn says, it's an array.  That is why only a variant works here.  You can test it with the following code:
Sub TT()
    Dim v As Variant
    v = Evaluate(ActiveSheet.Cells(1).Value)
    Stop
End Sub

Open in new window

Then, when it stops, you can see your variable in the Locals window:screenshotIf you're using Evaluate like this without knowing what is is in the cell you must assign to a Variant, then you can check what has been returned using Typename or a similar function.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:Anthony Mellor
ID: 37703645
ok, if it's anything but an array (as described) I don't care, so it can generate an error to its heart's content; this would as I understand it fit the bill for one of the hard data types (i.e. not the "soft" Variant), except there doesn't seem to be one that accepts arrays. in fact I can't find where it says that Variant accepts arrays, though empirically and clearly, it does.

Hence my question really, can't find it in the docs.

Anthony
0
 
LVL 50
ID: 37703671
You can declare an array with a specific data type, just like any other variable. If you omit the data type, it will be a variant.

Can you provide a bit more context on what you are trying to accomplish? In what scenario do you use evaluate? You mention Evaluate(A1), so there really is no VBA or declaration of data types involved that I can see.

Have a look at Chip Pearson's site for much info on arrays in VBA http://www.cpearson.com/excel/VBAArrays.htm

cheers, teylyn
0
 
LVL 42

Expert Comment

by:dlmille
ID: 37703895
It depends on what variable you assign it to, or how your function works.  I've been down the Evaluate path with you these past days- heck I started it I think, but that's not the only way you can interpret {1,2,3,4}.  You could build your own evaluate function (like I did for you earlier as an example assuming Evaluate didn't exist) reading it as a string.

Agree with what everyone else has said, with the exception that your code not using the Evaluate function can also evaluate it as a string.

Function getString(myStr as string) as string

   getString = left(myStr,3)

End Function

Of course, Evaluate sees it as an array, unless you improperly form it and it also sees it as a string, lol.

Use this against that {1,2;3,4} and you would get:

"{1,"

Cheers,

Dave
0
 
LVL 9

Author Comment

by:Anthony Mellor
ID: 37704436
If I seem confused, or unresponsive, see what you make of these:


by: teylynPosted on 2012-03-10 at 00:25:00ID: 37703671
You can declare an array with a specific data type, just like any other variable.

by: andrewssd3Posted on 2012-03-09 at 23:07:51ID: 37703434
As teylyn says, it's an array.  That is why only a variant works here.

by: ssaqibhPosted on 2012-03-09 at 21:39:06ID: 37703090
I think you can only use a string for that purpose.

by: dlmillePosted on 2012-03-10 at 02:14:13ID: 37703895
Agree with what everyone else has said, with the exception that your code not using the Evaluate function can also evaluate it as a string.

;-)

Yours sincerely,

Perplexed
0
 
LVL 9

Author Comment

by:Anthony Mellor
ID: 37712178
see above :-)
0
 
LVL 42

Accepted Solution

by:
dlmille earned 1000 total points
ID: 37712191
I was being cute.  Evaluate sees it as a variant array.

Dave
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question