Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Lookup first/last column of record
Hello
I want to lookup the first and last column of a record. It is a planning tool, in the columns are dates.in the records are tasks. I would like to search all column in the record. The first column is the begin date of my task, the last column is the end date of my task. Can someone help me? thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Lookup first/last column of record
Hi,
I'm a bit confused about finding the first used column in a row, don't you know where that is? To find that last date in a row try this =INDEX(1:1,MATCH(9.99999999999999E+307,1:1)) This is for row 1 so cjange to suit. Mike "Abrm" wrote: Hello I want to lookup the first and last column of a record. It is a planning tool, in the columns are dates.in the records are tasks. I would like to search all column in the record. The first column is the begin date of my task, the last column is the end date of my task. Can someone help me? thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Lookup first/last column of record
I want to lookup the first and last column of a record.
It is a planning tool, in the columns are dates.in the records are tasks. I would like to search all column in the record. The first column is the begin date of my task, the last column is the end date of my task. Assuming you are looking for a VBA solution (given that you posted in the programming newsgroup), you can use these two functions to get the information you seek... Function FindFirstDataCell(R As Range) As Range Dim X As Long For X = R.Column To R.Column + R.Count + 1 If Len(Cells(R.Row, X).Value) 0 Then Set FindFirstDataCell = Cells(R.Row, X) Exit For End If Next End Function Function FindLastDataCell(R As Range) As Range Dim X As Long For X = R.Column + R.Count + 1 To R.Column Step -1 If Len(Cells(R.Row, X).Value) 0 Then Set FindLastDataCell = Cells(R.Row, X) Exit For End If Next End Function Just pass in the range (for the row of interest) within your grid where the dates get filled in; since a range is returned, you can get the information about the first and last cell directly from the returned values. For example... Dim First As Range Dim Last As Range Set First = FindFirstDataCell(Range("D4:Q4")) Set Last = FindLastDataCell(Range("D4:Q4")) If Not First Is Nothing Then Debug.Print "First Date: " & First.Value & " in column " & First.Column End If If Not Last Is Nothing Then Debug.Print "Last Date: " & Last.Value & " in column " & Last.Column End If where I have assumed your dates are filled in from Column D through Column Q Rick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Record Lookup | Excel Discussion (Misc queries) | |||
lookup the next matching record. | Excel Worksheet Functions | |||
lookup information in a row like a record | Excel Worksheet Functions | |||
VBA: New Idea to lookup record | Excel Programming | |||
VBA: New Idea to lookup record | Excel Programming |