ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can you do IsEmpty(Range)? (https://www.excelbanter.com/excel-programming/369741-can-you-do-isempty-range.html)

Sharkbait

Can you do IsEmpty(Range)?
 
As I progress in VBA, I'm trying to make my macros more elegant and
less heavy-handed. One of those problems is how I end Do loops with
embedded If loops. I was previously just inserting a stop point in the
column. Something like 'Do Until ActiveCell = "End"'.
That works ok, until the range I'm working on is much shorter than my
stop range.

Is it possible to use IsEmpty to test a 15 cell block, and if they're
all empty to end, or insert my end point?

I've tried using the following code, but it doesn't work.

Range("C1").Select
Do Until ActiveCell = "ZZZ"
Range(ActiveCell, ActiveCell.Offset(15, 0)).Select
If IsEmpty(Selection) = True Then
ActiveCell.Offset(10, 0).Select
ActiveCell.FormulaR1C1 = "ZZZ"
Else: ActiveCell.Offset(5, 0).Select
End If
Loop

Thanks


Dave Peterson

Can you do IsEmpty(Range)?
 
You have a response at your other post.

Sharkbait wrote:

As I progress in VBA, I'm trying to make my macros more elegant and
less heavy-handed. One of those problems is how I end Do loops with
embedded If loops. I was previously just inserting a stop point in the
column. Something like 'Do Until ActiveCell = "End"'.
That works ok, until the range I'm working on is much shorter than my
stop range.

Is it possible to use IsEmpty to test a 15 cell block, and if they're
all empty to end, or insert my end point?

I've tried using the following code, but it doesn't work.

Range("C1").Select
Do Until ActiveCell = "ZZZ"
Range(ActiveCell, ActiveCell.Offset(15, 0)).Select
If IsEmpty(Selection) = True Then
ActiveCell.Offset(10, 0).Select
ActiveCell.FormulaR1C1 = "ZZZ"
Else: ActiveCell.Offset(5, 0).Select
End If
Loop

Thanks


--

Dave Peterson


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

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