Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Use IsEmpty on a range without a loop? XL03

IsEmpty addresses a single variable; IsEmpty(MyVar) determines if it has been
intialized.

I have a named range which is 12 cells. I want to identify when the first
cell has data but the other 11 cells are 'empty'. I've simplified the code
sample below, but I realize that it will be a 2-D array and which parameter
matters will depend on whether the data is in columns or rows... I'm just
trying to see if this is even possible.

My current option is to loop:

MyAbortCode = False
for i = 2 to 12
if IsEmpty(MyArray(i))=False then MyAbortCode = True
Next

If MyAbortCode = False then
'do stuff
End If


but I'm wondering if there is any way to do this all at once without a loop.

If IsEmpty(MyArray(2 to 12))= true then
'do stuff
End If

Thank you for any ideas,
Keith
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Use IsEmpty on a range without a loop? XL03

How about this?

If Application.CountA(MyArray) 1 Then

MsgBox "More than 1"
End If

HTH

Bob


"ker_01" wrote in message
...
IsEmpty addresses a single variable; IsEmpty(MyVar) determines if it has
been
intialized.

I have a named range which is 12 cells. I want to identify when the first
cell has data but the other 11 cells are 'empty'. I've simplified the code
sample below, but I realize that it will be a 2-D array and which
parameter
matters will depend on whether the data is in columns or rows... I'm just
trying to see if this is even possible.

My current option is to loop:

MyAbortCode = False
for i = 2 to 12
if IsEmpty(MyArray(i))=False then MyAbortCode = True
Next

If MyAbortCode = False then
'do stuff
End If


but I'm wondering if there is any way to do this all at once without a
loop.

If IsEmpty(MyArray(2 to 12))= true then
'do stuff
End If

Thank you for any ideas,
Keith



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Use IsEmpty on a range without a loop? XL03

If you're looking at a contiguous range, you could use:

with worksheets("Sheet999").range("SomeNameHere")
if application.count(.cells) = 0 then
'all cells are empty
else
'not all cells are empty
end if
End with

If you wanted to see if all were filled, you could use:

with worksheets("Sheet999").range("SomeNameHere")
if application.count(.cells) = .cells.count then
'all cells are filled
else
'not all cells are filled
end if
End with



ker_01 wrote:

IsEmpty addresses a single variable; IsEmpty(MyVar) determines if it has been
intialized.

I have a named range which is 12 cells. I want to identify when the first
cell has data but the other 11 cells are 'empty'. I've simplified the code
sample below, but I realize that it will be a 2-D array and which parameter
matters will depend on whether the data is in columns or rows... I'm just
trying to see if this is even possible.

My current option is to loop:

MyAbortCode = False
for i = 2 to 12
if IsEmpty(MyArray(i))=False then MyAbortCode = True
Next

If MyAbortCode = False then
'do stuff
End If

but I'm wondering if there is any way to do this all at once without a loop.

If IsEmpty(MyArray(2 to 12))= true then
'do stuff
End If

Thank you for any ideas,
Keith


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Use IsEmpty on a range without a loop? XL03

That did help me realize that the sample range I was working with was not the
one I thought :)

I have formulas in some source ranges (like the one I was working with) that
throws off the IsEmpty and CountA, but .Count will be perfect (I think- I
still need to do more testing).

Thank you Bob!
Keith

"Bob Phillips" wrote:

How about this?

If Application.CountA(MyArray) 1 Then

MsgBox "More than 1"
End If

HTH

Bob


"ker_01" wrote in message
...
IsEmpty addresses a single variable; IsEmpty(MyVar) determines if it has
been
intialized.

I have a named range which is 12 cells. I want to identify when the first
cell has data but the other 11 cells are 'empty'. I've simplified the code
sample below, but I realize that it will be a 2-D array and which
parameter
matters will depend on whether the data is in columns or rows... I'm just
trying to see if this is even possible.

My current option is to loop:

MyAbortCode = False
for i = 2 to 12
if IsEmpty(MyArray(i))=False then MyAbortCode = True
Next

If MyAbortCode = False then
'do stuff
End If


but I'm wondering if there is any way to do this all at once without a
loop.

If IsEmpty(MyArray(2 to 12))= true then
'do stuff
End If

Thank you for any ideas,
Keith



.

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
Data Validation drop-down width, with named range source (XL03 and ker_01 Excel Worksheet Functions 4 March 24th 10 03:31 PM
Loop Statement through If Not IsEmpty Then Paste into Destination Dandelo Excel Discussion (Misc queries) 7 July 15th 08 10:29 PM
Can you do IsEmpty(Range)? Sharkbait Excel Programming 1 August 8th 06 05:01 PM
IsEmpty on a range/array Norman Jones Excel Programming 3 September 7th 04 08:35 PM
Do.....Loop until IsEmpty(....) helmekki[_8_] Excel Programming 2 June 7th 04 03:15 PM


All times are GMT +1. The time now is 05:54 AM.

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"