Forum Discussion

GAutomation's avatar
GAutomation
Frequent Contributor
8 years ago

write a function to run the same row in excel

I have a cell which contain a value i excel. If that value fails then i need to click ok on the screen and run the previous row in t he excel again. How to write a  VB script function for it.

6 Replies

  • NisHera's avatar
    NisHera
    Valued Contributor

    assuming that you are working with excel DDT drive you can not go back in the loop.

    technically this is not TC limitation it is Ms-excel limitation.

     

    But you can use different technique , store previous row in an array https://www.w3schools.com/asp/func_array.asp

    0) define an array before you call DDT drive

    1) in your loop just before Call Driver.Next() , store your XL values in array

    2) In your xl values processing area put an IF condition like... if fails use array values.

     

     

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      I concur that, if you need to re-use values of the current row for some reason, simply store those values in some structure (object, array, variables, external file, etc)... that is if you need to cycle back through.  However, as long as you are still in the same iteration of the DDT loop, then you can just keep re-using the values until the loop recycles.  

    • GAutomation's avatar
      GAutomation
      Frequent Contributor
      row nostatusfunctionValue
      4enablevalidate value in tableabcd
      5enableclick button 

       

       

      If row table value validation fails then i want to write a function like the below one

      If Validate value in table = err
      click ok on the message box
      click ok again on the screen
      then go to row 4 and validate the value again

       

      Is this possible in VB script? Ours is keyword driven

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        The short answer is: yes.  Basically, while you're within the same loop, there's no need to "go to row 4".  You're already on row 4, you just exercise your logic as you have it written.  Until you go back through the loop a second time, the values in the current row (row 4) are still available to you.