Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default check for non-empty cells outside of a certain range

If I have a range of cells, say Range(Cells(1,1), Cells(50,50)), what
is the easiest way to check that all the other cells on that sheet have
no formulas or constants in them?

Thanks in advance,

Abe

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default check for non-empty cells outside of a certain range

Sub GetRealLastCell()
Dim RealLastRow As Long
Dim RealLastColumn As Long
On Error Resume Next
RealLastRow = _
Cells.Find("*", Range("A1"), , , xlByRows, xlPrevious).Row
RealLastColumn = _
Cells.Find("*", Range("A1"), , , xlByColumns, xlPrevious).Column
if RealLastRow 50 or RealLastColumn 50 then
msgbox "entries outside range"
else
msgbox "no entries outside range"
end if
End Sub

--
Regards,
Tom Ogilvy


"Abe" wrote:

If I have a range of cells, say Range(Cells(1,1), Cells(50,50)), what
is the easiest way to check that all the other cells on that sheet have
no formulas or constants in them?

Thanks in advance,

Abe


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default check for non-empty cells outside of a certain range

Tom,
Is that because you cannot trust the result of UsedRange ?

NickHK

"Tom Ogilvy" ...
Sub GetRealLastCell()
Dim RealLastRow As Long
Dim RealLastColumn As Long
On Error Resume Next
RealLastRow = _
Cells.Find("*", Range("A1"), , , xlByRows, xlPrevious).Row
RealLastColumn = _
Cells.Find("*", Range("A1"), , , xlByColumns, xlPrevious).Column
if RealLastRow 50 or RealLastColumn 50 then
msgbox "entries outside range"
else
msgbox "no entries outside range"
end if
End Sub

--
Regards,
Tom Ogilvy


"Abe" wrote:

If I have a range of cells, say Range(Cells(1,1), Cells(50,50)), what
is the easiest way to check that all the other cells on that sheet have
no formulas or constants in them?

Thanks in advance,

Abe




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default check for non-empty cells outside of a certain range

I trust it (usedrange) implicitly. It tells me what cells Excel is actually
maintaining data about. It tells me nothing about whether these cells can be
considered empty or not. So if I am trying to misuse it (drive a screw in
with a hammer) then the answer to your question would be yes. <g If I
recognized what it actually is for, then I am using my posted approach
because there is no built in command that will tell me what the extent of non
empty cells is (except special cells, but that would be more cumbersome).

--
Regards,
Tom Ogilvy






"NickHK" wrote:

Tom,
Is that because you cannot trust the result of UsedRange ?

NickHK

"Tom Ogilvy" ...
Sub GetRealLastCell()
Dim RealLastRow As Long
Dim RealLastColumn As Long
On Error Resume Next
RealLastRow = _
Cells.Find("*", Range("A1"), , , xlByRows, xlPrevious).Row
RealLastColumn = _
Cells.Find("*", Range("A1"), , , xlByColumns, xlPrevious).Column
if RealLastRow 50 or RealLastColumn 50 then
msgbox "entries outside range"
else
msgbox "no entries outside range"
end if
End Sub

--
Regards,
Tom Ogilvy


"Abe" wrote:

If I have a range of cells, say Range(Cells(1,1), Cells(50,50)), what
is the easiest way to check that all the other cells on that sheet have
no formulas or constants in them?

Thanks in advance,

Abe





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
Check for empty range in vba Phil Excel Discussion (Misc queries) 1 April 28th 06 09:57 PM
check a range of cells to see if they are empty L3Tech Excel Programming 1 March 25th 06 01:16 AM
Clear cells range if certain cells are all empty gschimek - ExcelForums.com Excel Programming 6 May 13th 05 10:38 PM
sum next two non-empty cells in a range Spencer Hutton Excel Worksheet Functions 1 January 9th 05 11:29 PM
Check for empty cells in Print Area? Ed Excel Programming 6 November 30th 04 06:15 PM


All times are GMT +1. The time now is 04:42 PM.

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"