Results 1 to 5 of 5

Finding a Date in Forumla via VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007; Excel 2010
    Posts
    178

    Finding a Date in Forumla via VBA

    Hi,

    I am having difficulty trying to find a date using VBA.

    I have a date range like so.

    Cell C5 =01/01/2012
    Cell D5 =C5+1
    Cell E5 = D5+1
    Cell F5 = E5+1

    Formatted as dd (day date only)

    Which gives me the dates ok

    When try to use find function in vba it just doesn't find any dates
    This is what I have
    Dim iRes As Integer, dFind As Date, strMonth As String, iM As Long
    Dim rngDate As Range
    
        iRes = MsgBox(Prompt:="Print range", Buttons:=vbYesNo)
        
        If iRes = vbNo Then
            Exit Sub
        ElseIf iRes = vbYes Then
            strMonth = Me.cboMonth.Text
            iM = Month(DateValue("01-" & strMonth & "-1900"))
            dFind = DateSerial(Me.txtYear.Value, iM, 1)
            Set rngDate = ActiveSheet.Range("C4:ND4").Find(what:=dFind, LookIn:=xlFormulas)
        End If
    rngDate always end up with nothing

    How do I go about the correct way?

    Thanks
    Last edited by Foreverlearning; 07-23-2012 at 05:28 PM.

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.6.0 RC 1