+ Reply to Thread
Results 1 to 4 of 4

check for non-empty cells outside of a certain range

  1. #1
    Abe
    Guest

    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. #2
    Tom Ogilvy
    Guest

    RE: 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. #3
    NickHK
    Guest

    Re: check for non-empty cells outside of a certain range

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

    NickHK

    "Tom Ogilvy" <[email protected]> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
    > 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. #4
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1