ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to check the array have value (https://www.excelbanter.com/excel-programming/349258-how-check-array-have-value.html)

x taol

how to check the array have value
 
Sub xx()
Dim an_x() As Long
k = 0
For i = 1 To 3
If k = 1 Then
ReDim Preserve an_x(1 To i)
an_x(i) = i + 6
End If
Next
'check whether an_x is empty or not empty.
'how can i know that the array is emptyed.

ubound or isarray or isempty or ismissing....
no ,no,no ???
End Sub


*** Sent via Developersdex http://www.developersdex.com ***

Norman Jones

how to check the array have value
 
Hi X Taol,

Try:
'===========
Sub xx()
Dim an_x() As Long
Dim k As Long, i As Long
Dim v As Variant

k = 0
For i = 1 To 3
If k = 1 Then
ReDim Preserve an_x(1 To i)
an_x(i) = i + 6
End If
Next

On Error Resume Next
v = UBound(an_x)
On Error GoTo 0

If IsEmpty(v) Then MsgBox "an_x is empty"

End Sub
'<<===========

---
Regards,
Norman



"x taol" wrote in message
...
Sub xx()
Dim an_x() As Long
k = 0
For i = 1 To 3
If k = 1 Then
ReDim Preserve an_x(1 To i)
an_x(i) = i + 6
End If
Next
'check whether an_x is empty or not empty.
'how can i know that the array is emptyed.

ubound or isarray or isempty or ismissing....
no ,no,no ???
End Sub


*** Sent via Developersdex http://www.developersdex.com ***





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

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