Retrieve values from excel sheet - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Retrieve values from excel sheet (/Thread-Retrieve-values-from-excel-sheet) |
Retrieve values from excel sheet - sravsand - 02-03-2011 In an excel sheet having many rows and columns, in this there are 2 columns those are questionnumber | Answers 1 a 2 c 3 b 1 c 4 d 2 d . . . . here my question is what is the percentage of answers for each question number, Output ex: QuestionNumber | a% | b%| c%| d%| 1 |50|0|50|0| 2 |0|0|50|50| like this for all question numbers. and this result should be inserted in new excel sheet Thanks inadvance RE: Retrieve values from excel sheet - anandanlk - 02-03-2011 Hi, Use the following logic just store in another excel(just name the 1st row headers as No, A, B, C and D respectively-one time) get the first row details from excel u have for example 1 a means so just add 1 to the 2nd column(A) of 1st Question No A B C D 1 1 get 2nd row from ur excel For ex 4 b means so just add 1 to the 3rd column(B) of 4th Question No A B C D 4 1 get 3rd row from ur excel For ex 1 b means so just add 1 to the 3rd column(B) of 1st Question No A B C D 1 1 1 get 4th row from ur excel For ex 1 b means so just add 1 to the 3rd column(B) of 1st Question No A B C D 1 1 2 likewise get all rows from ur excel and add values finally the excel will look like following No A B C D 1 1 2 2 0 2 2 2 0 0 3 1 1 2 1 Get total for each No A B C D tot 1 1 2 2 0 5 2 2 2 0 0 4 3 1 1 2 1 5 Result No A B C D tot A% B% C% D% 1 1 2 2 0 5 1/5*100 2/5*100 2/5*100 0 2 2 2 0 0 4 2/4*100 2/4*100 0 0 3 1 1 2 1 5 Note: if value is zero means dont divide. otherwise u will get zero divide exception I hope u know how to access values from excel RE: Retrieve values from excel sheet - sravsand - 02-03-2011 we don't know how many rows in questionnumber, it may have many rows, i need just filter all the rows by question number and percentages of answers. In the answers field it may have true/false or A,B,c. Could u please write the script for it. Thanks sandeep RE: Retrieve values from excel sheet - tarun - 02-04-2011 Try the below code Code: Set objExcel = CreateObject("Excel.Application") |