help! i'm new to using VBA with excel codes...
help people! :) i'm new to programming VB with excel data's... i'm currrently doing a program about a Hotline Log system in which the telephone operators log-in the time of the calls and also the time when the job was started and when it was finished. then they get the difference of the job finished and job started and logs it in the MTTR field (i forgot what MTTR stands for :confused: ) what i need to do is to return the values showing the total MTTR per day and also the total MTTR per owner(the technician who did the job) per day.
here's a part of the code which i can't figure out why i can't get the listbox to show the details.. is there something wrong with it? i'd appreciate if you guys would teach me on how to go about this problem... thanks! :D
--------------------
Public appExcel As Object
--------------
Private Sub Form_Initialize()
Dim wsheet As excel.Worksheet
Dim wbook As excel.Workbook
On Error Resume Next
Set appExcel = GetObject("C:\My Documents\Sample program\Sample1.xls") ', "Excel.Application")
Set wbook = appExcel.Application.Workbooks("sample1.xls")
Set wsheet = wbook.Sheets("SHEET1")
max_row = wsheet.UsedRange.Rows.Count
max_col = wsheet.UsedRange.Columns.Count
wbook.Windows(1).Visible = True
wbook.Application.Visible = False
Dim MTTRvalue As String
'selects the values on range a starting with row2
curRow = 2
wsheet.Range("A" & curRow).Select
curDate = wsheet.Range("A" & curRow).Value
curRow = curRow + 1
'checks if the values of the dates are thesame
While curDate <> ""
wsheet.Range("A" & curRow).Select
edate = wsheet.Range("A" & curRow).Value
'if the values of the dates are thesame, the calculation is then performed and the total MTTR is being displayed in the list box together with the date
If edate = curDate Then
MTTRtotal = MTTRtotal + wsheet.Range("F" & curRow).Value
Else
MTTRvalue$ = Format$(MTTRtotal, "#.00")
MTTRvalue$ = Space(12 - Len(MTTRvalue$)) & MTTRvalue
Listbox1.AddItem edate & Chr(9) & Chr(9) & MTTRvalue$
MTTRtotal = wsheet.Range("F" & curRow).Value
curDate = edate
InvCounter = InvCounter + 1
End If
Wend
End Sub