Forum Discussion

OV's avatar
OV
Frequent Contributor
7 years ago

How do i get eh number of value in en excel file in specific column?

Hi,

 

I'm reading an excel file with few columns and want to select random value from specific column. and i have problem with 2 things:

 

1. I want to select the column by its header or index

 

2. Once i found the right header each column had different values and different number of values below, for those values i would like to select a random value. my question is how do i determine how many values i have for each column so i can use the Random(min, max) func to select a random value.

 

My script:

 

// Open Devices_ModelSetup.xlsx for reading
oExcelApp.Workbooks.Open("C:\\TestComplete Database\\Devices_ModelSetup.xlsx");
for(i = 1; i <= 12; i++)
if(SeriesValueFromUI == VarToString(oExcelApp.Cells(1, i)))
NumberOfModels = oExcelApp.Cells.Range
for(k = 1; VarToString(oExcelApp.Cells(k, i)) != "" ; k++)
ModelValue = VarToInt(oExcelApp.Cells(Random(1, k), i))

 

Thanks

4 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What is it that you are trying to accomplish with this?  Maybe we can find you an easier way to do it.

    • OV's avatar
      OV
      Frequent Contributor

      Hi Marsha,

       

      I have few printers models, for each printer model i've created a row in an excel file, each printer model had sub-models but, each printer has a different number of sub-models.

       

      I want to randomly select a printer and then randomly  select printer's sub-model, means i first need to get the number of sub-models under the printer i've selected and then select this value from a combobox.

       

      Thanks,

       

      OV