George
Member
Hi All,
I'm having a little trouble with loading a column from a table to an array. I've posted the code below, and the error message I get is "type mismatch", but I thought you could assign anything to a Variant (please let me know if I'm wrong about this).
Thanks in advance,
George
I'm having a little trouble with loading a column from a table to an array. I've posted the code below, and the error message I get is "type mismatch", but I thought you could assign anything to a Variant (please let me know if I'm wrong about this).
Thanks in advance,
George
Code:
Public Sub GenerateAppts()
Dim InstRng As Range
Dim InstArr() As Variant
Dim InstTypeArr() As Variant
Dim AllTypeArr() As Variant
Dim i As Double
Dim j As Double
Dim iws As Worksheet
Dim sws As Worksheet
Dim iTblNm As String
Set sws = ThisWorkbook.Sheets("Summary")
Set InstRng = ThisWorkbook.Sheets("Summary").Range("InstanceList")
InstArr() = InstRng
'loop through all instances and run SQLappts on it, adding worksheets as required
For i = 1 To UBound(InstArr)
SQLappts CStr(InstArr(i, 1))
'set iws as the worksheet name for the instance (error handling for this covered in SQLappts)
Set iws = ThisWorkbook.Sheets(CStr(InstArr(i, 1)))
iTblNm = CStr(InstArr(i, 1)) & "Tbl"
'make sure the InstTypeArr array is empty
Erase InstTypeArr
'set the InstTypeArray as the Type column from the instance table. NOT WORKING!
InstTypeArr() = iws.Range(iws.iTblNm & "[Type]")
For j = LBound(InstTypeArr) To UBound(InstTypeArr)
'stuff will happen here
Next j
Next i
End Sub