A
Andy
Hi guys
I have a blank workbook (FindIP.xls) in which I am writing a macro.
The macro brings up the file dialogue and allows a user to choose an
Excel spreadsheet to open up. No problems.
I then want to read a column of IP addresses (text) from the selected
worksheet and put them into an array for further processing. I am
'Activating' the selected worksheet to make it the active worksheet and
then assigning a range to a variant array (vArray). After the
assignment, the LBounds and UBounds functions return the correct
numbers however when the debugger says the array is empty. How can the
UBound be correct but the array is apparently empty??
Any thoughts appreciated.....Andrew
Here is the offending code...
'************ Get workbook name *****************************
varLen = Len(varFilePath)
varStartPoint = InStr(varFilePath, "N62")
varFileName = Right(varFilePath, ((varLen - varStartPoint) + 1))
'************ Load Daily IP's into array *********************
Workbooks(varFileName).Activate 'Make the select workbook the active
workbook
'Find last row in IP column
LastRowInCol = ActiveSheet.Range("G65536").End(xlUp).Row
'Capture IP numbers from IP column into an array
vArray = Sheet1.Range("G2:G" & LastRowInCol)
'Get the array bounds to manage loop 'This works!'
varLBound = LBound(vArray)
varUBound = UBound(vArray)
'//************ Loop through the list of IPs from spreadsheet array
***************//
For i = 1 To (varUBound - 1)
varArrayValue = vArray(i, 1) ' **** !!!! PROBLEM HERE - says
array is empty.
I have a blank workbook (FindIP.xls) in which I am writing a macro.
The macro brings up the file dialogue and allows a user to choose an
Excel spreadsheet to open up. No problems.
I then want to read a column of IP addresses (text) from the selected
worksheet and put them into an array for further processing. I am
'Activating' the selected worksheet to make it the active worksheet and
then assigning a range to a variant array (vArray). After the
assignment, the LBounds and UBounds functions return the correct
numbers however when the debugger says the array is empty. How can the
UBound be correct but the array is apparently empty??
Any thoughts appreciated.....Andrew
Here is the offending code...
'************ Get workbook name *****************************
varLen = Len(varFilePath)
varStartPoint = InStr(varFilePath, "N62")
varFileName = Right(varFilePath, ((varLen - varStartPoint) + 1))
'************ Load Daily IP's into array *********************
Workbooks(varFileName).Activate 'Make the select workbook the active
workbook
'Find last row in IP column
LastRowInCol = ActiveSheet.Range("G65536").End(xlUp).Row
'Capture IP numbers from IP column into an array
vArray = Sheet1.Range("G2:G" & LastRowInCol)
'Get the array bounds to manage loop 'This works!'
varLBound = LBound(vArray)
varUBound = UBound(vArray)
'//************ Loop through the list of IPs from spreadsheet array
***************//
For i = 1 To (varUBound - 1)
varArrayValue = vArray(i, 1) ' **** !!!! PROBLEM HERE - says
array is empty.