ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a simple date match?? |:( (https://www.excelbanter.com/excel-programming/381090-simple-date-match-%7C.html)

[email protected]

a simple date match?? |:(
 
Hello experts,

I hope one of you ca help me out with something (very simple,
probably...).

On one sheet i have a date, and i want to lookup that date in a
different sheet and get the row number.
Ive tried a bunch of diffent matches, but i simply can get it to work..
Any help on this would be really appreciated!

Thanks in Advance

Leen

best-code-so-far-that-ive-been-able-to-think-of :

Sub test()
Dim data_row As Integer
dim date_val as string

date_val= Cells(ActiveCell.Column)
date_row = Application.Match(date_val, Worksheets("data").Range("B:B"),
0)

MsgBox date_row


End Sub


[email protected]

a simple date match?? |:(
 
I've actually managed to com up with something that works! (it did take
me quite a few hours in the end, despite these post -timestamps :)


addr= Replace(Cells(1, ActiveCell.Column).Address, "$", "")

date_row = Application.Match(Range(addr),
Worksheets("data").Range("B:B"), 0)


If anyone knows a better option, please do reply - dates in excel do
seem to elude me!


Tom Ogilvy

a simple date match?? |:(
 
dim res as Variant
Dim rng as Range

res = Application.Match(clng(Cells(1,ActiveCell.Column). Value), _
Worksheets("Data").Range("B:B"),0)
if iserror(res) then
msgbox "Not found"
exit sub
end if
set rng = Worksheets("Data").Cells(res,2)

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
I've actually managed to com up with something that works! (it did take
me quite a few hours in the end, despite these post -timestamps :)


addr= Replace(Cells(1, ActiveCell.Column).Address, "$", "")

date_row = Application.Match(Range(addr),
Worksheets("data").Range("B:B"), 0)


If anyone knows a better option, please do reply - dates in excel do
seem to elude me!





All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com