Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Record Lookup Tojib Excel Discussion (Misc queries) 0 May 6th 08 10:44 PM
lookup the next matching record. tess Excel Worksheet Functions 5 April 4th 07 03:17 PM
lookup information in a row like a record utraceme Excel Worksheet Functions 1 April 18th 05 05:05 PM
VBA: New Idea to lookup record Mcasteel[_12_] Excel Programming 0 October 27th 04 03:34 AM
VBA: New Idea to lookup record Mcasteel[_11_] Excel Programming 2 October 26th 04 10:02 PM


All times are GMT +1. The time now is 03:45 AM.

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"