Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Return the Row of a Variable's location

I'm a total beginner with VBA, so my apologies up front.
I have a table with Column A filled with dates.
I am trying to locate the row number of the cell that contains the
matching date to my variable named LASTDATE. How do I do this?
Thanks.
Robert

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Return the Row of a Variable's location

Sub marine()
LASTDATE = DateValue("12/30/2006")
For i = 1 To 100
If Cells(i, "A").Value = LASTDATE Then
MsgBox (Cells(i, "A").Row)
Exit Sub
End If
Next
End Sub


and in the worksheet column A has:
=TODAY()
=A1+1
=A2+1
=A3+1
=A4+1
=A5+1
=A6+1
=A7+1
=A8+1
=A9+1
=A10+1
=A11+1
=A12+1
=A13+1
=A14+1
=A15+1
=A16+1
=A17+1
=A18+1
=A19+1
=A20+1
=A21+1
=A22+1
=A23+1
and displays:
12/22/2006
12/23/2006
12/24/2006
12/25/2006
12/26/2006
12/27/2006
12/28/2006
12/29/2006
12/30/2006
12/31/2006
1/1/2007
1/2/2007
1/3/2007
1/4/2007
1/5/2007
1/6/2007
1/7/2007
1/8/2007
1/9/2007
1/10/2007
1/11/2007
1/12/2007
1/13/2007
1/14/2007

Note the use of the function DateValue()
--
Gary's Student


"xjetjockey" wrote:

I'm a total beginner with VBA, so my apologies up front.
I have a table with Column A filled with dates.
I am trying to locate the row number of the cell that contains the
matching date to my variable named LASTDATE. How do I do this?
Thanks.
Robert


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
VBA reseting variables bpeltzer Excel Discussion (Misc queries) 0 February 4th 06 03:52 PM
Huge problem with "if" formula's [email protected] Excel Discussion (Misc queries) 16 July 20th 05 07:20 PM
return zero from a blank cell Eric Excel Worksheet Functions 5 July 15th 05 11:23 PM
Excel - return a picture or range rows as the result of a formula juststarting Excel Worksheet Functions 1 July 4th 05 12:59 AM
Pivot Table Zero Value jcliquidtension Excel Discussion (Misc queries) 12 January 13th 05 04:21 AM


All times are GMT +1. The time now is 09:07 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"