+ Reply to Thread
Results 1 to 3 of 3

Thread: Macro to jump to cell/row containing todays date

  1. #1
    Registered User
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2003, 2007
    Posts
    34

    Macro to jump to cell/row containing todays date

    Ok first off, this is the very first time I've ever tried using VBA/Macros etc. So please, baby-steps and simple explanations needed


    I have a sheet with dates running down collumn B (If it makes any difference, one date covers 2x cells that are merged - so 1st november covers B127 & B128, 2nd November covers B129 & B130). These 2 cells are the only cells merged for that date row
    All dates are written as 01/11/2011, and formatted to show 01-Nov.

    I simply need a macro (or if a button can be added to the sheet?) that when it's run, jumps to the cell or row(s) (as one date covers 2x rows) containing todays date

    Already had a look at this thread and tried the following:


    Private Sub Worksheet_Activate()
    Dim Dt As Date
        
        Dt = Date
        Columns("B:B").Select
        Range("B1").Activate
    
        Selection.Find(What:=Dt, After:=ActiveCell, LookIn:=xlFormulas _
        , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False).Select
    
    End Sub
    ...and looked at the example sheet there, but when I go into Macro (Alt+F8) to run it, there is nothing there to run...

    I've also tried

    Sub Finddate()
        Dim c As Range
         
        Set c = ActiveSheet.Cells.Find(what:=Date, LookIn:=xlValues)
        If Not c Is Nothing Then c.Select
         
    End Sub
    Which does give me a macro called 'Sheet1.Finddate' but when I run it, nothing happens.

    Thanks

  2. #2
    Forum Guru
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,108

    Re: Macro to jump to cell/row containing todays date

    The reason you can't see "Worksheet_Activate" is because it's "Private". It also has a reserved Sub Name.
    Excel automatically executes it when the sheet it's attached to is activated.

    My 1st thought is that your dates in the sheet are formulas not values, just displayed as dates.

    My 2nd thought is that the dates in the sheet have times included in them (just not displayed) and Date has a time of 00:00.

    After that I would have to see the workbook.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  3. #3
    Registered User
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2003, 2007
    Posts
    34

    Re: Macro to jump to cell/row containing todays date

    Attached is an example file that I hope helps.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0