Hey guys, new to the forum. I'm having troubles with a script I have. What I'm trying to do is search an excel sheet for a particular string in the first column. I want to find the row number and display the corresponding column info. Below is the test one I've been using to figure out my issue. It seems that the loop doesn't like my strWord variable for some reason, although putting "9873" directly into the loop seems to work fine. Is there something I have to do for my defined variable to work? Thanks.
Dim intRow, strWord, strExcel, strPositionID, strLocation, strIncomingCalls, strOutgoingCalls
strWord = "9873"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\Query\test.xls")
intRow = 1
Do Until objExcel.Cells(intRow,1).Value = strWord
intRow = intRow + 1
Loop
strPositionID = objExcel.Cells(intRow, 2).Value
strLocation = objExcel.Cells(intRow, 3).Value
strIncomingCalls = objExcel.Cells(intRow, 2).Value
strOutgoingCalls = objExcel.Cells(intRow, 3).Value
objExcel.Workbooks(1).Close
objExcel.Quit
Msg = msgBox ("User ID: " & strUserName & vbNewLine & "Computer Name: " & strCharacters & vbNewLine & "Position ID:" & strPositionID & vbNewLine & "Location:" & strLocation & vbNewLine & "Incoming Calls:" & strIncomingCalls & vbNewLine & "Outgoing Calls:" & strOutgoingCalls)
Dim intRow, strWord, strExcel, strPositionID, strLocation, strIncomingCalls, strOutgoingCalls
strWord = "9873"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\Query\test.xls")
intRow = 1
Do Until objExcel.Cells(intRow,1).Value = strWord
intRow = intRow + 1
Loop
strPositionID = objExcel.Cells(intRow, 2).Value
strLocation = objExcel.Cells(intRow, 3).Value
strIncomingCalls = objExcel.Cells(intRow, 2).Value
strOutgoingCalls = objExcel.Cells(intRow, 3).Value
objExcel.Workbooks(1).Close
objExcel.Quit
Msg = msgBox ("User ID: " & strUserName & vbNewLine & "Computer Name: " & strCharacters & vbNewLine & "Position ID:" & strPositionID & vbNewLine & "Location:" & strLocation & vbNewLine & "Incoming Calls:" & strIncomingCalls & vbNewLine & "Outgoing Calls:" & strOutgoingCalls)