Enetring data in an expanding table

N

NDBC

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
 
J

Jacob Skaria

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
 
J

JLatham

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
 
D

Don Guillett

How about a drop down list tied to a macro to find the selection and then
find the 1st free column?
 
N

NDBC

Thanks,
Just what I needed.

JLatham said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top