Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Can't test for Empty objects in an array

I'm writing Excel macros using VBA under XP and I'm having a problem testing
for Empty objects in an array.

The debugger shows an element is Empty, but if I separately test for either
'Is Empty' or 'Is Nothing' I
get 'Object required'

Thanks for your help,
Peter.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Can't test for Empty objects in an array

Hi Peter,

I created a (0 to 4) array; I loaded worksheets into array positions 1, 2
and three.

In consequence, array positions 0 and 4 were empty. I tested each position,
using an IsEmpty condition and, as expected, the test returned false for
postions 1-3 and True for positions 0 and 4:


Sub Tester()

Dim Arr(0 To 4)
Dim i As Long
Dim j As Long

For i = 1 To 3
Set Arr(i) = ActiveWorkbook.Sheets(i)
Next i

For j = LBound(Arr) To UBound(Arr)
MsgBox IsEmpty(Arr(j))
Next j

End Sub


---
Regards,
Norman



"Peter Chatterton" wrote in message
.. .
I'm writing Excel macros using VBA under XP and I'm having a problem
testing for Empty objects in an array.

The debugger shows an element is Empty, but if I separately test for
either 'Is Empty' or 'Is Nothing' I
get 'Object required'

Thanks for your help,
Peter.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Can't test for Empty objects in an array

Thanks a lot Norman.

What I ended up doing was:
If aAllArrays(ID_WS, i) Is Empty Then Exit For

Peter.


"Norman Jones" wrote in message
...
Hi Peter,

I created a (0 to 4) array; I loaded worksheets into array positions 1, 2
and three.

In consequence, array positions 0 and 4 were empty. I tested each
position, using an IsEmpty condition and, as expected, the test returned
false for postions 1-3 and True for positions 0 and 4:


Sub Tester()

Dim Arr(0 To 4)
Dim i As Long
Dim j As Long

For i = 1 To 3
Set Arr(i) = ActiveWorkbook.Sheets(i)
Next i

For j = LBound(Arr) To UBound(Arr)
MsgBox IsEmpty(Arr(j))
Next j

End Sub


---
Regards,
Norman



"Peter Chatterton" wrote in message
.. .
I'm writing Excel macros using VBA under XP and I'm having a problem
testing for Empty objects in an array.

The debugger shows an element is Empty, but if I separately test for
either 'Is Empty' or 'Is Nothing' I
get 'Object required'

Thanks for your help,
Peter.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Can't test for Empty objects in an array

Hi Peter,

What I ended up doing was:
If aAllArrays(ID_WS, i) Is Empty Then Exit For


Are you sure that syntax works for you?

---
Regards,
Norman



"Peter Chatterton" wrote in message
.. .
Thanks a lot Norman.

What I ended up doing was:
If aAllArrays(ID_WS, i) Is Empty Then Exit For

Peter.


"Norman Jones" wrote in message
...
Hi Peter,

I created a (0 to 4) array; I loaded worksheets into array positions 1, 2
and three.

In consequence, array positions 0 and 4 were empty. I tested each
position, using an IsEmpty condition and, as expected, the test returned
false for postions 1-3 and True for positions 0 and 4:


Sub Tester()

Dim Arr(0 To 4)
Dim i As Long
Dim j As Long

For i = 1 To 3
Set Arr(i) = ActiveWorkbook.Sheets(i)
Next i

For j = LBound(Arr) To UBound(Arr)
MsgBox IsEmpty(Arr(j))
Next j

End Sub


---
Regards,
Norman



"Peter Chatterton" wrote in message
.. .
I'm writing Excel macros using VBA under XP and I'm having a problem
testing for Empty objects in an array.

The debugger shows an element is Empty, but if I separately test for
either 'Is Empty' or 'Is Nothing' I
get 'Object required'

Thanks for your help,
Peter.







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
How can I test if a cell is empty? Victor Delta Excel Discussion (Misc queries) 10 August 8th 07 11:22 PM
Test if the range is empty dan Excel Discussion (Misc queries) 6 December 21st 06 03:59 PM
Test for end of array of objects? peter Excel Programming 8 February 3rd 05 09:15 AM
Test if Clipboard is empty Tod Excel Programming 1 August 17th 04 05:00 PM
Better way to test for empty Recordset Tod Excel Programming 1 April 2nd 04 05:19 PM


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

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

About Us

"It's about Microsoft Excel"