J
Jac Tremblay
Hi,
I read a post where someone tried to get the number of lines in a named
range in a closed workbook. Unfortunately, there has been no follow up on
that post.
I am interested in knowing if that is possible. I tried the following code:
' ****************************************
Sub NbLinesInRange()
Dim lngNbLines As Long
Dim wbk As Excel.Workbook
Dim sht As Excel.Worksheet
Dim rng As Range
Set wbk = Workbooks("C:\TestFile.xls")
Set sht = wbk.Worksheets("Data")
Set rng = sht.Range("TestName")
lngNbLines = rng.Rows.Count
MsgBox "lngNbLines = " & lngNbLines
Set wbk = Nothing
Set sht = Nothing
Set rng = Nothing
End Sub
' ****************************************
I get an error on the line:
Set wbk = Workbooks("C:\TestFile.xls")
I wander if it is a question of missing reference or if is not possible all
together.
The VBA project has a reference on ADO 2.5.
Thanks for any help.
I read a post where someone tried to get the number of lines in a named
range in a closed workbook. Unfortunately, there has been no follow up on
that post.
I am interested in knowing if that is possible. I tried the following code:
' ****************************************
Sub NbLinesInRange()
Dim lngNbLines As Long
Dim wbk As Excel.Workbook
Dim sht As Excel.Worksheet
Dim rng As Range
Set wbk = Workbooks("C:\TestFile.xls")
Set sht = wbk.Worksheets("Data")
Set rng = sht.Range("TestName")
lngNbLines = rng.Rows.Count
MsgBox "lngNbLines = " & lngNbLines
Set wbk = Nothing
Set sht = Nothing
Set rng = Nothing
End Sub
' ****************************************
I get an error on the line:
Set wbk = Workbooks("C:\TestFile.xls")
I wander if it is a question of missing reference or if is not possible all
together.
The VBA project has a reference on ADO 2.5.
Thanks for any help.