View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Enetring data in an expanding table

This could be assigned to a button to ask for the lap time and rider number
and will put the lap time in the 1st available column when the rider number
match is made:

Sub AddLaps()
Dim ridersRange As Range
Dim riderCell As Range
Dim lapTime As String
Dim riderNumber As String

lapTime = InputBox$("Enter lap time", "Lap Time", "")
riderNumber = InputBox$("Enter Rider Number", "Rider", "")
If lapTime = "" Or riderNumber = "" Then
Exit Sub
End If
Set ridersRange = Range("H5:" & _
Range("H" & Rows.Count).End(xlUp).Address)
Set riderCell = ridersRange.Find(riderNumber, , xlValues)
If Not riderCell Is Nothing Then
Range("G" & riderCell.Row).End(xlToRight).Offset(0, 1) = lapTime
End If
Set ridersRange = Nothing
Set riderCell = Nothing
End Sub


"Jacob Skaria" wrote:

The below code identifies the next free column in the current row..where the
cell is selected...and input the time.

lngCol = ActiveSheet.Cells(ActiveCell.Row, _
Columns.Count).End(xlToLeft).Column + 1
ActiveSheet.Cells(ActiveCell.Row,lngCol) = Now()

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

This is my table


Rider Lap 1 Lap2 ........

100
101
102


I need to select the cell to store data in based on rider number and then
the first free lap time cell. ie. lap 1 time in lap1 and then when get to
next lap determine next available cell over and put lap2 time. If it helps
rider is in column h and 100 is in row 5.

Thanks yet again