ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select cell = today() (https://www.excelbanter.com/excel-programming/370370-select-cell-%3D-today.html)

[email protected]

Select cell = today()
 
Hi, I'd like to create a macro which selects the cell in a column which
is equal to Today() or the next date following.

I have set up a task list in Excel and Column C has a list of
historical and future dates. As I'm a novice, can anyone assist in
providing a macro to be this? I am playing around with the 'nextrow'
argument but not getting anywhere.

thanks

Nelson


Dave Peterson

Select cell = today()
 
Maybe...

Option Explicit
Sub testme02()

Dim wks As Worksheet
Dim myCol As Range
Dim res As Variant
Dim FirstDate As Long

Set wks = ActiveSheet

Set myCol = wks.Range("C1").EntireColumn

FirstDate = CLng(Date)

res = Application.Match(FirstDate, myCol, 0)

If IsError(res) Then
res = Application.Match(FirstDate + 1, myCol, 0)
End If

If IsError(res) Then
MsgBox "Today and Tomorrow weren't found!"
Else
myCol.Cells(1)(res).Select
End If

End Sub




wrote:

Hi, I'd like to create a macro which selects the cell in a column which
is equal to Today() or the next date following.

I have set up a task list in Excel and Column C has a list of
historical and future dates. As I'm a novice, can anyone assist in
providing a macro to be this? I am playing around with the 'nextrow'
argument but not getting anywhere.

thanks

Nelson


--

Dave Peterson

Tom Ogilvy

Select cell = today()
 
Dim rng as Range, res as Variant, res1 as Variant
set rng = Range(Cells(1,1),Cells(1,1).End(xldown))
res = application.Match(clng(date),rng,0)
res1 = application.Match(clng(date + 1),rng,0)
if not iserror(res) then
rng(res).Select
elseif not iserror(res1) then
rng(res1).Select
else
msgbox "Not found"
end if

--
Regards,
Tom Ogilvy

wrote in message
ps.com...
Hi, I'd like to create a macro which selects the cell in a column which
is equal to Today() or the next date following.

I have set up a task list in Excel and Column C has a list of
historical and future dates. As I'm a novice, can anyone assist in
providing a macro to be this? I am playing around with the 'nextrow'
argument but not getting anywhere.

thanks

Nelson





All times are GMT +1. The time now is 08:15 AM.

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