Populating a 2-D array
If you don't like typing """" here is a slight variation:
Sub Tester4()
sStr = "{7,8,9,1,2,3,4,5,6,@;" _
& "3,4,5,7,8,@,9,1,2,@;" _
& "@,3,4,5,7,@,8,9,2,@;" _
& "@,9,@,2,4,@,5,7,8,@;" _
& "@,8,@,9,@,@,2,4,7,@;" _
& "@,9,@,@,@,@,2,7,8,@;" _
& "@,@,@,@,@,@,8,9,7,@}"
sStr = Application.Substitute(sStr, "@", """""")
Debug.Print sStr
vote = Application.Evaluate(sStr)
Debug.Print LBound(vote, 1), UBound(vote, 1)
Debug.Print LBound(vote, 2), UBound(vote, 2)
End Sub
--
Regards,
Tom Ogilvy
Dave Peterson wrote in message
...
Something like:
Dim Vote As Variant
Vote = Application.Evaluate( _
"{7,8,9,1,2,3,4,5,6,"""";" _
& "3,4,5,7,8,"""",9,1,2,"""";" _
& """"",3,4,5,7,"""",8,9,2,"""";" _
& """"",9,"""",2,4,"""",5,7,8,"""";" _
& """"",8,"""",9,"""","""",2,4,7,"""";" _
& """"",9,"""","""","""","""",2,7,8,"""";" _
&
""""","""","""","""","""","""",8,9,7,""""}")
Each double quote gets doubled:
"" becomes """"
This line:
& """"",3,4,5,7,"""",8,9,2,"""";" _
has double quotes surrounding this string:
"""",3,4,5,7,"""",8,9,2,"""";
since it's a string.
Beto wrote:
Tom Ogilvy wrote:
Not using brackets. You can with Evaluate.
How would that go????
Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.
This is how to do it, courtesy of Dana DeLouis
W=[{7,1,5,6;6,1,5,25;4,1,5,23}]
HTH
Bob Phillips
Thanks for this elegant solution, which works well for me. I have
applied
it to a 7 x 10 array, but had to put it all on one enormous line.
The
usual line continuation character ( _) seems not to work. Is there
a work
around for this?
Vote =
[{7,8,9,1,2,3,4,5,6,"";3,4,5,7,8,"",9,1,2,"";"",3,4 ,5,7,"",8,9,2,"";"",9,"",
2,4,"",5,7,8,"";"",8,"",9,"","",2,4,7,"";"",9,""," ","","",2,7,8,"";"","","",
"","","",8,9,7,""}]
--
Dave Peterson
|