View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default cell selection code

Kudos to you for using DIM statements before using variables in your code.
Very good programming practice that will help prevent typographic errors from
causing problems you may not easily detect.

You can 'force' yourself to do this by setting the "Require Variable
Declaration" option under Tools -- Options in the VB Editor itself. This
will automatically add an
Option Explicit
statement at the very beginning of all new code modules. If you have not
been doing that, you can add that statement as the first line to existing
modules to get the same results.

"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