Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 21
Default TESTING FOR EMPTY ARRAY

I am downloading a 2-dimensional, zero-based, Variant array from
Bloomberg for various securities. For any given security, there are
three situations: 1) the array is empty; 2) there are two elements
(one row, two columns); or 3) there are two or more elements in each
column. There will always be an equal number of elements in each
column. My code needs to be able to distinguis between situation 1
and situation 2; the LBound(Dimension 1) and UBound(Dimension 1) are
zero for each. When testing LBound(Dimension 2) and UBound(Dimension
2) for situation 1, I get the error "Subscript out of range".

I have tried the following:
If Not IsArray(vtData(x, 0)) Then 'where x = 0 To UBound(Dimension
1)
Result == both situation 1 and 2, value is False

and
If IsEmpty(vtData(0, 0)(x, 0) 'where x = 0 To UBound(Dimension 1)
Result == for situation 1, I get the error "Subscript out of range".

Help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default TESTING FOR EMPTY ARRAY

I think you already have the answer. If UBound = 0, then your have
situation 1. Don't do any more testing.

"JingleRock" wrote:

I am downloading a 2-dimensional, zero-based, Variant array from
Bloomberg for various securities. For any given security, there are
three situations: 1) the array is empty; 2) there are two elements
(one row, two columns); or 3) there are two or more elements in each
column. There will always be an equal number of elements in each
column. My code needs to be able to distinguis between situation 1
and situation 2; the LBound(Dimension 1) and UBound(Dimension 1) are
zero for each. When testing LBound(Dimension 2) and UBound(Dimension
2) for situation 1, I get the error "Subscript out of range".

I have tried the following:
If Not IsArray(vtData(x, 0)) Then 'where x = 0 To UBound(Dimension
1)
Result == both situation 1 and 2, value is False

and
If IsEmpty(vtData(0, 0)(x, 0) 'where x = 0 To UBound(Dimension 1)
Result == for situation 1, I get the error "Subscript out of range".

Help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default TESTING FOR EMPTY ARRAY

Dim ub2 as Long
Dim bSit1 as Boolean
if Ubound(v,1) = 0 then

on Error Resume Next
ub2 = Ubound(v,2)
if err < 0 then _
bSit1 = True

on Error goto 0

if bSit1 then

--
Regards,
Tom Ogilvy

"JingleRock" wrote:

I am downloading a 2-dimensional, zero-based, Variant array from
Bloomberg for various securities. For any given security, there are
three situations: 1) the array is empty; 2) there are two elements
(one row, two columns); or 3) there are two or more elements in each
column. There will always be an equal number of elements in each
column. My code needs to be able to distinguis between situation 1
and situation 2; the LBound(Dimension 1) and UBound(Dimension 1) are
zero for each. When testing LBound(Dimension 2) and UBound(Dimension
2) for situation 1, I get the error "Subscript out of range".

I have tried the following:
If Not IsArray(vtData(x, 0)) Then 'where x = 0 To UBound(Dimension
1)
Result == both situation 1 and 2, value is False

and
If IsEmpty(vtData(0, 0)(x, 0) 'where x = 0 To UBound(Dimension 1)
Result == for situation 1, I get the error "Subscript out of range".

Help.


  #4   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 21
Default TESTING FOR EMPTY ARRAY

On Aug 27, 12:04 pm, Joel wrote:
I think you already have the answer. If UBound = 0, then your have
situation 1. Don't do any more testing.



Maybe this was not clear:
My code needs to be able to distinguish between situation 1
and situation 2; the LBound(Dimension 1) and UBound(Dimension 1) are
zero for each.

  #5   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 21
Default TESTING FOR EMPTY ARRAY

Tom,

Thank you very much, again.
Your code works great.

JingleRock

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Testing of an array Lord Robocop Excel Worksheet Functions 1 May 7th 09 03:22 AM
Testing for empty sheet Stu W Excel Programming 2 July 4th 07 09:28 PM
empty cells - best way of testing for them Chris Strug Excel Programming 3 August 10th 04 11:53 AM
Testing for null or empty gwgeller[_3_] Excel Programming 4 January 29th 04 08:34 PM
testing for non-empty cells Paul James[_2_] Excel Programming 6 August 3rd 03 09:04 AM


All times are GMT +1. The time now is 02:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"