x
login register about faq

How to select random rows and cols from excel using QTP

How to select random rows and cols from excel using QTP
more ▼

asked Dec 22 '11 at 08:45 PM

deven21 gravatar image

deven21
1 1 1 1

(comments are locked)
10|600 characters needed characters left

3 answers: sort voted first

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
more ▼

answered Feb 23 '12 at 12:10 PM

Rich Text gravatar image

Rich Text ♦
4k 37 5 45

(comments are locked)
10|600 characters needed characters left

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

more ▼

answered Dec 27 '11 at 02:00 PM

bubblehead712 gravatar image

bubblehead712 ♦♦
12.9k 112 93 146

(comments are locked)
10|600 characters needed characters left
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.
more ▼

answered Mar 01 '12 at 02:01 PM

Dan gravatar image

Dan
3.5k 62 2 8

(comments are locked)
10|600 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments


 

Stuff we like

Orasi Software
Perfecto Mobile

Topics:

x341
x51

asked: Dec 22 '11 at 08:45 PM

Seen: 2178 times

Last Updated: Dec 27 '11 at 01:41 PM

(c) 2013 Orasi Software, Inc.