Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Find Date from formula

Trying to help out another poster and am stuck with a dilemma.
Dates are not my forte.

I have a date from one sheet stored in a variable:

Dim eDate As String
eDate = Range("A" & Target.Row).Value

MsgBox eDate results in "8/28/03"

Now I need to find that date in column "A" of another sheet.
That part would be easy except for the fact that the dates in
column A are the result of formulas:
The corresponding date 8/28/03 in column A is represented
by the formula ='2003'!A283

How (or is it possible) to search the formulas in column A
where the result of the formula would equal 8/28/03??

I'm actually looking to get the corresponding row number of
where the match is found.

Thanks,
John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find Date from formula

Option Explicit
Sub FindDate()
Dim rng As Range, rng1 As Range
Dim edate As Date
Dim res As Variant
Set rng = Worksheets("sheet1").Range("A9")
edate = rng.Value
With Worksheets("Sheet2")
Set rng1 = .Range(.Cells(1, 1), .Cells(365, 1))
End With
res = Application.Match(CLng(edate), rng1, 0)
If Not IsError(res) Then
MsgBox "found at " & rng(res).Address(external:=True)
End If
End Sub

Worked for me. Cells in Sheet2 were formulas.

--
Regards,
Tom Ogilvy


"John Wilson" wrote in message
...
Trying to help out another poster and am stuck with a dilemma.
Dates are not my forte.

I have a date from one sheet stored in a variable:

Dim eDate As String
eDate = Range("A" & Target.Row).Value

MsgBox eDate results in "8/28/03"

Now I need to find that date in column "A" of another sheet.
That part would be easy except for the fact that the dates in
column A are the result of formulas:
The corresponding date 8/28/03 in column A is represented
by the formula ='2003'!A283

How (or is it possible) to search the formulas in column A
where the result of the formula would equal 8/28/03??

I'm actually looking to get the corresponding row number of
where the match is found.

Thanks,
John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Find Date from formula

Tom,

Thank you very much for that.
Apologies for not posting a reply sooner.
Tried it on the workbook that I was helping someone with and
it didn't work. Not your fault. Your code works perfectly in a test
workbook, but the workbook I was trying to use this on has a
number of blank cells in column "A" (forgot to mention that caveat).
As it turns out, the OP"did" want the information on the same sheet
(meaning that a simple Offset would do the trick) and he'll pull that
information onto his main sheet via formulas (made it a lot easier
for me).

Anyway, I will save your code for future reference as I'm sure
I'll come across a similar scenario again and thanks for giving
me just a little bit more insight into dates in Excel which I think
only you and a select few others truly understand. Hopefully,
someday, I'll be part of that select few.

Thanks again,
John

"Tom Ogilvy" wrote in message
...
Option Explicit
Sub FindDate()
Dim rng As Range, rng1 As Range
Dim edate As Date
Dim res As Variant
Set rng = Worksheets("sheet1").Range("A9")
edate = rng.Value
With Worksheets("Sheet2")
Set rng1 = .Range(.Cells(1, 1), .Cells(365, 1))
End With
res = Application.Match(CLng(edate), rng1, 0)
If Not IsError(res) Then
MsgBox "found at " & rng(res).Address(external:=True)
End If
End Sub

Worked for me. Cells in Sheet2 were formulas.

--
Regards,
Tom Ogilvy


"John Wilson" wrote in message
...
Trying to help out another poster and am stuck with a dilemma.
Dates are not my forte.

I have a date from one sheet stored in a variable:

Dim eDate As String
eDate = Range("A" & Target.Row).Value

MsgBox eDate results in "8/28/03"

Now I need to find that date in column "A" of another sheet.
That part would be easy except for the fact that the dates in
column A are the result of formulas:
The corresponding date 8/28/03 in column A is represented
by the formula ='2003'!A283

How (or is it possible) to search the formulas in column A
where the result of the formula would equal 8/28/03??

I'm actually looking to get the corresponding row number of
where the match is found.

Thanks,
John





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
Array formula to find date Amylou Excel Worksheet Functions 0 March 25th 10 04:17 PM
Formula to find the date closest to today. jem264 Excel Discussion (Misc queries) 3 February 26th 10 06:27 PM
Using formula to find out a Date 90 prior to a particular date Vinod Excel Worksheet Functions 2 June 15th 09 12:09 PM
why can't I change the date with find and replace in this formula MLTDebbie Excel Worksheet Functions 0 January 30th 08 08:52 PM
Find under date formula? David Excel Discussion (Misc queries) 6 October 26th 05 08:25 PM


All times are GMT +1. The time now is 09:46 PM.

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"