Micro Focus QTP (UFT) Forums
Parameterize Excel Columns for 2-Dimensional Array - 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: Parameterize Excel Columns for 2-Dimensional Array (/Thread-Parameterize-Excel-Columns-for-2-Dimensional-Array)



Parameterize Excel Columns for 2-Dimensional Array - defcon3 - 06-19-2012

Hi Guys

I'm trying copy data from a 2-dimensional array into an Excel sheet but the problem I'm having is how can I move to the next column of the Excel sheet using a For Loop to go through the array.

The excel sheet columns are labelled "A","B" etc, how can I move to the next column without having to write a statement for each column.
.
.
.
Code:
For i=0 to Some_value
  For j= 0 to Some_value
    objWorkSheet.cells(i+1, "A")=MyArray(i,j)
   Next
Next
.

The rows are fine because they're a parameter of the For Loop but how can I parameterize the columns so I can use j to keep track of the column.


RE: Parameterize Excel Columns for 2-Dimensional Array - sshukla12 - 06-20-2012

Hi,
Instead of specifying the column label use column number to pass the values
for ex:
Code:
For i=0 to Some_value
  For j= 0 to Some_value
    objWorkSheet.cells(i+1, [color=#FF0000]j+1[/color])=MyArray(i,j)
   Next
Next

Let me know in case of any help required.

Regards,
Sankalp


RE: Parameterize Excel Columns for 2-Dimensional Array - defcon3 - 06-20-2012

Thanks for your input, will using the column number work without me going into preferences to make Excel show column numbers instead of letters?