Closed Thread
Results 1 to 3 of 3

Inspecting cells in a row in a named range

  1. #1
    Jim
    Guest

    Inspecting cells in a row in a named range

    I have a large named range on my worksheet and want to have my code inspect
    every cell in the first and last row only and NOT ispect every cell.

    How can I modify my code to inspect the first row cell values?

    Dim DataCell As Range
    Dim FieldName As Name

    For Each FieldName In ThisWorkBook.Names
    If Not FieldName Is Nothing Then

    For Each DataCell In Range(FieldName) 'Loops thru all names
    Debug.Print "cell: ", DataCell.Cells.Value
    Next DataCell

    Endif
    Next FieldName

    thanks.



  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Jim,

    This examines the first and last rows of data.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Jim
    Guest

    Re: Inspecting cells in a row in a named range

    Works great. (For anyone else using this, there is a trivial spelling error:
    "Colummns." vice "Columns")

    thanks

    "Leith Ross" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hello Jim,
    >
    > This examines the first and last rows of data.
    >
    >
    > Code:
    > --------------------
    > Dim FirstRow As Long
    > Dim LastRow As Long
    > Dim FirstColumn As Long
    > Dim LastColumn As Long
    > Dim DataCell As Range
    > Dim FieldName As Name
    >
    > For Each FieldName In ThisWorkBook.Names
    > If Not FieldName Is Nothing Then
    >
    > Set DataCell = Range(FieldName)
    >
    > With DataCell
    > FirstRow = .Row
    > LastRow = .Rows.Count - FirstRow + 1
    > FirstColumn = .Column
    > LastColumn = .Colummns.Count - FirstColumn + 1
    > End With
    >
    > 'Examine First Row of Data
    > For C = FirstColumn To LastColumn
    > Debug.Print "cell: ", DataCell.Cells(FirstRow, C).Value
    > Next C
    >
    > 'Examine Last Row of Data
    > For C = FirstColumn To LastColumn
    > Debug.Print "cell: ", DataCell.Cells(LastRow, C).Value
    > Next C
    >
    > Endif
    >
    > Next FieldName
    >
    > --------------------
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile:
    > http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=484994
    >




Closed 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