This is my code below:
I dont want to create a new spreadsheet. I want to open an existing spreadsheet. Where and how do i do this?Code:Function searchdata() Dim objBooks As Excel.Workbooks Dim objsheets As Excel.Sheets Dim objsheet As Excel.Worksheet Dim range As Excel.Range 'create a new instance of Excel and start a new workbook objApp = New Excel.Application objBooks = objApp.Workbooks objBook = objBooks.Add objsheets = objBook.Worksheets objsheet = objsheets(1) 'get the range where the starting cell has the address 'm_sStartingCell and its dimensions are m_iNumRows x m_iNumCols range = objsheet.Range("Q2", "AC5001") a = 0 b = 1 r = 2 'row Do Do If aclient(a) <> "" And aport(b) <> "" Then Do If aclient(a) = objsheet.Range("ABr").Value And portnum(b) = objsheet.Range("Qr").Value Then bytes(a, b) = ((bytes(a, b) + objsheet.Range("Zr").Value)) Else r += 1 End If Loop Until objsheet.Range("ABr").Value = "null" End If b += 1 r = 2 Loop Until b = 6 a += 1 b = 1 r = 2 Loop Until a = 10 End Function




Reply With Quote