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
Bookmarks