jimrobinson
New Member
- Joined
- Feb 6, 2012
- Messages
- 5
The following fails:
Private Sub GetHierarchy(htable As Variant)
Dim ws As Worksheet
Dim cmax As Integer
Dim rmax As Integer
' Dim htable As Variant
Set ws = Sheets("Hierarchy")
cmax = LastColumn(ws)
rmax = LastRow(ws)
htable = ws.Range(Cells(1, 1), Cells(rmax, cmax))
End Sub
This works:
Private Sub GetHierarchy(htable As Variant)
Dim ws As Worksheet
Dim cmax As Integer
Dim rmax As Integer
' Dim htable As Variant
Set ws = Sheets("Hierarchy")
cmax = LastColumn(ws)
rmax = LastRow(ws)
ws.Select
htable = ActiveSheet.Range(Cells(1, 1), Cells(rmax, cmax))
End Sub
I'd like to use the former, because it's more efficient
Do I chalk this up as a bug, and use the latter?
Excel 2010
( its the last line in the subroutine that fails)
If I make a demo subroutine without a parameter, and define htable
dim htable variant
the demo subroutine doesn't get failure
e.g.
Private Sub demo()
Dim ws As Worksheet
Dim cmax As Integer
Dim rmax As Integer
Dim htable As Variant
Set ws = Sheets("Hierarchy")
cmax = LastColumn(ws)
rmax = LastRow(ws)
htable = ws.Range(Cells(1, 1), Cells(rmax, cmax))
End Sub
Thanks,
Jim
Private Sub GetHierarchy(htable As Variant)
Dim ws As Worksheet
Dim cmax As Integer
Dim rmax As Integer
' Dim htable As Variant
Set ws = Sheets("Hierarchy")
cmax = LastColumn(ws)
rmax = LastRow(ws)
htable = ws.Range(Cells(1, 1), Cells(rmax, cmax))
End Sub
This works:
Private Sub GetHierarchy(htable As Variant)
Dim ws As Worksheet
Dim cmax As Integer
Dim rmax As Integer
' Dim htable As Variant
Set ws = Sheets("Hierarchy")
cmax = LastColumn(ws)
rmax = LastRow(ws)
ws.Select
htable = ActiveSheet.Range(Cells(1, 1), Cells(rmax, cmax))
End Sub
I'd like to use the former, because it's more efficient
Do I chalk this up as a bug, and use the latter?
Excel 2010
( its the last line in the subroutine that fails)
If I make a demo subroutine without a parameter, and define htable
dim htable variant
the demo subroutine doesn't get failure
e.g.
Private Sub demo()
Dim ws As Worksheet
Dim cmax As Integer
Dim rmax As Integer
Dim htable As Variant
Set ws = Sheets("Hierarchy")
cmax = LastColumn(ws)
rmax = LastRow(ws)
htable = ws.Range(Cells(1, 1), Cells(rmax, cmax))
End Sub
Thanks,
Jim