How to select random rows and cols from excel using QTP
Question ID: 104438
0
0

How to select random rows and cols from excel using QTP

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on December 22, 2011 8:45 pm
222 views
Answers (3)
2
Private answer

I find it also helpful if you place the Randomize command before the Rnd call. This 'seats' the random number generator to avoid patterns.

Randomize

irow= Int((MaxRows * Rnd) + 1)

Randomize

icolumn= Int((MaxColumns * Rnd) + 1)

Just a little tip

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on February 23, 2012 12:10 pm
0
Private answer

Have you tried to use the Rnd Function? I have not done this but would think it look like this:


MaxRows = 10  'Maximum number of rows
MaxColumns = 5 'Maximum number of columns 
sfilePath =  'pathe to Excel file
isheet =    '  Sheet to use

irow= Int((MaxRows * Rnd) + 1)  
icolumn= Int((MaxColumns * Rnd) + 1)

Set ExcelObj = CreateObject(''Excel.Application'')
ExcelObj.Workbooks.Open sfilePath
Set NewSheet = ExcelObj.Sheets.Item(isheet)
value = NewSheet.Cells(irow,icolumn)
ExcelObj.Application.Quit
Set ExcelObj = Nothing
 

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 27, 2011 2:00 pm
0
Private answer

Also if you set the sheet, you can use the vbscript to get the columns and rows for the sheet, then assign those to the appropriate max variables and use what is actually available on your particular sheet for true randomness for your particular sheet.

Marked as spam
Posted by (Questions: 0, Answers: 770)
Answered on March 1, 2012 2:01 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top