View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default cell selection code

Hi,

Ridercell is a range so

Dim ridercell as range

Lapcol is a row number so dim as long

Dim LapCol as long

What I didn't post in my reply is how I tested this and did so by setting up
some variables like this

Dim LapCol As Long, RiderCell As Range
LapCol = 1
Set RiderCell = Range("a1")
LastLap = Format(Sheets("A Grade").Cells(RiderCell.Row, LapCol).Value,
"hh:mm.ss")

So with a time of 00:00:10 in A1 it correctly returned 00:00.10
Mike

"NDBC" wrote:

Mike

Thanks for that. In the interim I had thought that maybe my dim statements
for the lastlap and lapcol were wrong. I deleted the dim statement altogether
for those 2 and then it seemed to work. How should they be set.


"Mike H" wrote:

As long as your sure your row/column coordinates are correct then try this

LastLap = Format(Sheets("A Grade").Cells(ridercell.Row, lapcol).Value,
"hh:mm.ss")

Mike

"NDBC" wrote:

I am trying to get the time (lastlap) from Worksheet (A Grade) when i know it
is located in the nth column (lapcol) and the nth row ridercell.row. I have
checked that the row and column co-ordinates are right but I don't think this
code works. It is returning 0 when it should have been the time 0:00:10. Is
it something to do with the number being in a time format.

LastLap = Sheets("A Grade").Cells(riderCell.Row, LapCol).Value

Thanks again