Sunday, October 30, 2011

How to find in which row or column,string "Textword" exist in excel sheet


Set ObjExcel=CreateObject("Excel.Application")
ObjExcel.Workbooks.Open("E:\path\Test.xlsx")
Set Obj=ObjExcel.Sheets.Item(1)
rowcount=Obj.usedrange.rows.count
colcount=Obj.usedrange.columns.count
For i=1 to rowcount
  For j=1 to colcount
       Aval=Obj.Cells(i,j)
          If StrComp(Aval,"Textword")=0 then
                 MsgBox "Location Is : ("&i&","&j&")"
                 Exit For
                 Exit For          
          End If
Next
Next
obj=nothing
objExcel=nothing