PDA

View Full Version : Solved: Initializing Entire Array at Once:: Syntax Error



Saladsamurai
10-22-2009, 11:07 AM
What is the Syntax Error that I keep getting nailed on? Is it the line continuation char?

Dim CaseArray() As String

CaseArray = ("BenchMark", "Cooler 1 - 14","Cooler 1 - 3","Cooler 1 - 8", _
"Cooler 2 - 10","Cooler 2 - 4","Cooler 3 - 12","Cooler 3 - 3","Cooler 3 - 8", _
"Cooler 4 - 12","Cooler 4 - 5","Cooler A - 14","Cooler A - 3","Cooler A - 8", _
"Cooler C - 12","Cooler C - 3","Cooler C - 8")

Saladsamurai
10-22-2009, 11:17 AM
Got it!

Dim CaseArray() As String

CaseArray = Array("BenchMark", "Cooler 1 - 14","Cooler 1 - 3","Cooler 1 - 8", _
"Cooler 2 - 10","Cooler 2 - 4","Cooler 3 - 12","Cooler 3 - 3","Cooler 3 - 8", _
"Cooler 4 - 12","Cooler 4 - 5","Cooler A - 14","Cooler A - 3","Cooler A - 8", _
"Cooler C - 12","Cooler C - 3","Cooler C - 8")

Saladsamurai
10-22-2009, 11:22 AM
No I don't! Now when I run it I get a 'Type MisMatch' and it highlights

CaseArray = Array("BenchMark", "Cooler 1 - 14","Cooler 1 - 3","Cooler 1 - 8", _
"Cooler 2 - 10","Cooler 2 - 4","Cooler 3 - 12","Cooler 3 - 3","Cooler 3 - 8", _
"Cooler 4 - 12","Cooler 4 - 5","Cooler A - 14","Cooler A - 3","Cooler A - 8", _
"Cooler C - 12","Cooler C - 3","Cooler C - 8")

Saladsamurai
10-22-2009, 11:46 AM
Alright, now I Dimmed the Array as Variant, which I hate doing, and that worked to clear the Error.

Now I have a new problem:

The value of CaseArray(0) = "Benchmark"

Why can't I use the line

.Cells(1,1) = CaseArray(0)

I tried appending ".Value" and ".Text" but to no avail.

I keep getting "Object Var or With Block Var Not Set"

GTO
10-22-2009, 06:28 PM
Greetings,

Sub exa()
Dim CaseArray
CaseArray = Array("BenchMark", "Cooler 1 - 14", "Cooler 1 - 3", "Cooler 1 - 8", _
"Cooler 2 - 10", "Cooler 2 - 4", "Cooler 3 - 12", "Cooler 3 - 3", "Cooler 3 - 8", _
"Cooler 4 - 12", "Cooler 4 - 5", "Cooler A - 14", "Cooler A - 3", "Cooler A - 8", _
"Cooler C - 12", "Cooler C - 3", "Cooler C - 8")

With Worksheets("Sheet1")
.Cells(1, 1) = CaseArray(0)
End With

End Sub


...should work. I would suspect that the problem lies in some part of the procedure that you did not post.

Mark