ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is Array Empty | Boolean Answer (https://www.excelbanter.com/excel-programming/297133-array-empty-%7C-boolean-answer.html)

verizon

Is Array Empty | Boolean Answer
 
Hello

I have a subroutine that may or may not be presented with an array. If an
array has not been presented, then it should take the array from the current
worksheet:

Sub CreateTAPPIndex(Optional TAPPMatrix As Variant)
If IsEmpty(TAPPMatrix) Then
Rem This section understands when the matrix is a raw sheet versus a
presented array
Range("2:2").EntireRow.Delete
TAPPMatrix = Range("a1").CurrentRegion.Value
End If
End Sub

But if TAPPMatrix is undefined, it does NOT trigger a TRUE response from
IsEmpty. What am I doing wrong? Is there a better way?

Thank you

W



Vasant Nanavati

Is Array Empty | Boolean Answer
 
Try IsMissing instead of IsEmpty. I think it will work.

--

Vasant

"verizon" wrote in message
...
Hello

I have a subroutine that may or may not be presented with an array. If an
array has not been presented, then it should take the array from the

current
worksheet:

Sub CreateTAPPIndex(Optional TAPPMatrix As Variant)
If IsEmpty(TAPPMatrix) Then
Rem This section understands when the matrix is a raw sheet versus

a
presented array
Range("2:2").EntireRow.Delete
TAPPMatrix = Range("a1").CurrentRegion.Value
End If
End Sub

But if TAPPMatrix is undefined, it does NOT trigger a TRUE response from
IsEmpty. What am I doing wrong? Is there a better way?

Thank you

W





No Name

Is Array Empty | Boolean Answer
 
Another way:

Sub CreateTAPPIndex(Optional TAPPMatrix As Variant)
Dim N As Long, ArrIsNull As Boolean
On Error Resume Next
N = TAPPMatrix.Count
On Error GoTo 0
ArrIsNull = N = 0
End Sub

PB


-----Original Message-----
Hello

I have a subroutine that may or may not be presented with

an array. If an
array has not been presented, then it should take the

array from the current
worksheet:

Sub CreateTAPPIndex(Optional TAPPMatrix As Variant)
If IsEmpty(TAPPMatrix) Then
Rem This section understands when the matrix is a

raw sheet versus a
presented array
Range("2:2").EntireRow.Delete
TAPPMatrix = Range("a1").CurrentRegion.Value
End If
End Sub

But if TAPPMatrix is undefined, it does NOT trigger a

TRUE response from
IsEmpty. What am I doing wrong? Is there a better way?

Thank you

W


.



All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com