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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 11:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com