View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim[_60_] Jim[_60_] is offline
external usenet poster
 
Posts: 6
Default 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" wrote
in message ...

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