Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
empty range
How do I write a procedure to look at a range of cells, and if all the cells
are empty do one thing, or if at least on cell in the range has something in it do something else? I tried Sub a() Dim r As Range Set r = Range("rng") r.Select If r is empty Then MsgBox ("nothing") Else MsgBox ("something") End If End Sub That doesn't seem to work. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
empty range
Sub emptcheck()
For Each r In Selection If IsEmpty(r) Then Else MsgBox ("at least on cell in this range has content") Exit Sub End If Next MsgBox ("the cells in this range are empty") End Sub -- Gary''s Student - gsnu200770 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
empty range
That works
Thank You "Gary''s Student" wrote: Sub emptcheck() For Each r In Selection If IsEmpty(r) Then Else MsgBox ("at least on cell in this range has content") Exit Sub End If Next MsgBox ("the cells in this range are empty") End Sub -- Gary''s Student - gsnu200770 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
empty range
If application.counta(r) 0 then
msgbox "at least one cell is non-empty" else msgbox "all empty" end if ranswert wrote: How do I write a procedure to look at a range of cells, and if all the cells are empty do one thing, or if at least on cell in the range has something in it do something else? I tried Sub a() Dim r As Range Set r = Range("rng") r.Select If r is empty Then MsgBox ("nothing") Else MsgBox ("something") End If End Sub That doesn't seem to work. Thanks -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
empty range
ranswert wrote:
How do I write a procedure to look at a range of cells, and if all the cells are empty do one thing, or if at least on cell in the range has something in it do something else? It depends on what you mean by "empty". The suggestions of both Gary's Student and Dave Peterson will treat as not empty an empty string; i.e., the contents of a cell into which you type the formula ="" Alan Beban |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Last Empty Row in Range | Excel Programming | |||
Range ... how to know if it is empty | Excel Programming | |||
Finding next empty empty cell in a range of columns | Excel Programming | |||
Range empty? | Excel Programming | |||
why is range empty? | Excel Discussion (Misc queries) |