Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting cell number from excel sheet
#1
Not Solved
Hi

I am writing a QTPScript(vbscript) to get cell information from excel sheet.I am able to create excel object,sheet etc.

There is a cell in sheet(1) which conatins a string "Result".How will I get this cell number using excel object?
Reply
#2
Not Solved
hi,

You can use following code. You can also iterate for all the columns as well

row
Code:
rowCount= DataTable.Getsheet("Global").RowCount
For i = 1 to rowCount
        DataTable.GetSheet("Global").SetCurrentRow i        
        If    DataTable.Value(<Column Name>, "Global") = "Result" Then
                                      MsgBox Found
                          end If

You mean cell number.
ok on top of what I have mentioned above you can use the following statement to find the Cell Value.

Code:
cellValue=workSheets("1").range(<your range of columns>.Value
range of the column could be ($P$1) like that.
Reply
#3
Not Solved
Thanks for the reply

But I should know the column name for this.I dont know that....Without that I need the cell number.
Reply
#4
Not Solved
Try this code

Code:
Set ObjExcel = CreateObject("Excel.Application")
ObjExcel.visible = TRUE
Set sWorkbook = ObjExcel.Workbooks.Open("z:\Sample1.xls")
Set sWorksheet = sWorkbook.Worksheets("Sheet1")

rCnt = sWorkbook.Worksheets("Sheet1").UsedRange.Rows.Count
cCnt = sWorkbook.Worksheets("Sheet1").UsedRange.Columns.Count
For i = 1 to rCnt

    For j = 1 to cCnt

        cValue = sWorkbook.Worksheets("Sheet1").Cells(i,j).Value
        If cValue = "Result" Then
            Print "Row Number - " & i & "  Column Number " & j
        End If

    Next

Next
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading data from excel sheet serenediva 1 9,620 03-03-2017, 10:07 AM
Last Post: vinod123
  How import final calculated values by cell formula from Excel not the formula itself. qtped 1 4,861 01-17-2017, 04:05 PM
Last Post: sagar.raythatha
Smile Importing Excel sheet - Reference Values are not recognized michiusa69 3 7,885 01-23-2015, 02:36 AM
Last Post: lkng2001
  How to pass a date from Excel sheet to web form revati.shendure 1 2,968 11-27-2014, 11:54 AM
Last Post: revati.shendure
  clearing excel sheet values beejfred 1 7,514 09-25-2014, 11:43 AM
Last Post: vinod123

Forum Jump:


Users browsing this thread: 1 Guest(s)