Results 1 to 2 of 2

search for Value between Dates specified

Threaded View

  1. #1
    Registered User
    Join Date
    08-01-2008
    Location
    london
    Posts
    1

    search for Value between Dates specified

    Hi Can anyone tell me how to find the minimum value in a table between two dates specified in cells ( e.g D1 and D2) of the current Sheet:

    also when i get the minValue how do i set the Cell where i find this minvalue to be the activeCell?

    since i have the minvalue as 'answer' i am not sure how to set the Cell where i find the value of the 'answer' variable to be the active Cell


    please see my code below:

    Private Sub cmdCalculate_Click()
        Dim myRange   As Range
        Dim minRange  As Range
        
        Dim myDate    As Date
        Dim minDate   As Date
        Dim maxDate   As Date
        Dim SheetData As Worksheet
        
           
       'Get Date Ranges to search within
        minDate = Worksheets("Instructions").Range("D2")
        maxDate = Worksheets("Instructions").Range("D3")
           
        'Set the Ranges of all the Cells to look for min value , but also the Date  (minDate, maxDate) ranges needs to be set as well and incoporated here
        Set myRange = Worksheets("Data").Range("B2:K1828")
        answer = Application.WorksheetFunction.Min(myRange)
        
        'Set the Cell of the Minvalue Variable to be the ActiveCell
        minRange = Range("answer").Activate - this does not work either
     
       'Get the Date by  offset from the activeCell (Minimum value which was set   as the active Cell)
       'Worksheets("Data").Activate
        myDate = ActiveCell.Offset(0, -4)
           
        MsgBox "minvalue:" & answer & "  " & "Date occurence:" & myDate
        
        'put the in value in the instructions workSheet D8 & D9 Respectively
        Worksheets("Instructions").Range("D8") = answer
        Worksheets("Instructions").Range("D9") = myDate
           
    End Sub
    Thanks
    Last edited by VBA Noob; 08-01-2008 at 08:28 AM.

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