PDA

View Full Version : Solved: Type Mismatch?



Saladsamurai
12-11-2009, 06:49 AM
I don't get it :dunno 3 lines of code and things are already going south....what is it...Monday?

Sub RunMixedMetrics()


Dim MyPath As String
Dim WorkBookNames() As String

MyPath = ActiveWorkbook.Path
'Debug.Print MyPath

WorkBookNames = Array("Mixed_20L6W Metrics.xls")


End Sub

Saladsamurai
12-11-2009, 07:52 AM
Switched to Variant and all is well.

Bob Phillips
12-11-2009, 07:57 AM
Why would you create an array with just one item?

Saladsamurai
12-11-2009, 08:11 AM
Why would you create an array with just one item?

Because I'm an a$$hole. :)




Or I am just testing things at the moment.:*) :grinhalo:

Bob Phillips
12-11-2009, 08:37 AM
This works without variant types



Sub RunMixedMetrics()

Dim MyPath As String
Dim WorkBookNames(1 To 100) As String

MyPath = ActiveWorkbook.Path
'Debug.Print MyPath

WorkBookNames(1) = "Mixed_20L6W Metrics.xls"

End Sub

Saladsamurai
12-11-2009, 09:15 AM
This works without variant types



Sub RunMixedMetrics()

Dim MyPath As String
Dim WorkBookNames(1 To 100) As String

MyPath = ActiveWorkbook.Path
'Debug.Print MyPath

WorkBookNames(1) = "Mixed_20L6W Metrics.xls"

End Sub


Yeah...I had hoped to initialize it all at once. But this makes me wonder why my OP didn't work? What is different other than the fact that you DImmed the Array from 1 to 100 ? Weird...