A Macros to Pull Data from an automated Excel Sheet

[Closed]
Report
Posts
1
Registration date
Friday January 3, 2014
Status
Member
Last seen
January 3, 2014
-
Hello,

I have a running spreadsheet where the data is automatically updated. On a separate sheet I am trying to pull information off the main spreadsheet. I want to make a drop down list of a certain equipment and pull the data between a certain time framefor that in the main spreadsheet and sum up the total in that time frame. I am new to Macros, so the code may be completely wrong. The information I am pulling is in this format, [h];mm:ss, but the dates I am comparing to is mm/dd/yyyy hh:mm.

Here is the code I have so far

Dim TitleGiven
Dim TitleData As Date
Dim StartGiven As Date
Dim StartData As Date
Dim EndGiven As Date
Dim EndData As Date
Dim OutageCount As Date


TitleGiven = Sheets("DownTime").Cells(2, 1)
StartGiven = Sheets("DownTime").Cells(2, 2)
EndGiven = Sheets("DownTime").Cells(3, 2)

LastOutageRow = Sheets("PAI Commercial Operation").UsedRange.Rows.Count

For OutageCount = 3 To LastOutageRow

TitleData = Sheets("PAI Commercial Operation").Cells(OutageCount, 10)

NewDownTime = Sheets("PAI Commercial Operation").Cells(OutageCount, 6)

If TitleGiven = TitleData Then
StartData = Sheets("PAI Commercial Operation").Cells(OutageCount, 4)
EndData = Sheets("PAI Commercial Operation").Cells(OutageCount, 5)

If StartGiven >= StartData And EndGiven <= EndData Then
Totaldowntime = Totaldowntime + NewDownTime
End If

End If

Next

Range("B4").Value = Totaldowntime

End Sub

Your help is appreciated. Thank you