@hughabbott (Hugh Abbott) posted a new topic, subject "For each row loop return row number". It read:

   kinda embarrassed to ask this … and I know the answer is something really simple
    
    when, I'm looping through, how do I return the current row number ?
    
    (I know I could create a int and just count that but there must be an inbuilt variable?)

After which, @prasath17 (Guru) added

    @hughabbott \- You mean cell address ? like A22, B15 etc…

Then @NIVED_NAMBIAR (NIVED N) said

    Hi @hughabbott  
    There is an index property in for each row which returns the row index of current row

After which, @hughabbott (Hugh Abbott) added

    could you give me an example.
    
    row.index or something like that ?

To which @hughabbott (Hugh Abbott) replied

    actually, I thinking about a “For Each Row” activity.
    
    If I wanted to have a message box tell me which row is the current row number … how might I get that ?

To which @NIVED_NAMBIAR (NIVED N) replied

    Hi @hughabbott  
    Check this workflow  
    Main.xaml (7.5 KB)
    
    Regards
    
    Nived N
    
    Happy Automation

After which, @hughabbott (Hugh Abbott) added

    Nived - I wonder if you might type in the line of code ( I could not open the xaml file because of a version conflict )
    
    thanks for your help thusfar.
    
    Hugh

To which @NIVED_NAMBIAR (NIVED N) replied

    Hi @hughabbott
    
    image1305×737 26.7 KB
    
    Here index variable is created in index property of for each row
    
    Please Note
    
    Regards
    
    Nived N
    
    Happy Automation

@Edenilson_Fernandes_dos_S (Edenilson Fernandes dos Santos) replied

    Hello if the intention is to discover an excel line to write in it, I use the following method.
    
    The activity ( **LookUp Range** ) does a search in excel for something of your criteria, a text for example, and returns the cell, except for A5, then you save it in a Var.
    
    To write in excel in C5 for example.  
    Use **Write Cell** , and as input Var.Replace(“A”, “C”)
    
    Write in the cell, in the line with the value found, but in column C.
    
    busca_excel765×1329 72.4 KB
    
      
    
    
    Main.xaml (10.2 KB) teste.xlsx (9.1 KB)

Then @hughabbott (Hugh Abbott) said

    image1274×574 24.7 KB
    
      
    I wonder what I am doing wrong ?

@NIVED_NAMBIAR (NIVED N) replied

    Can u show the property panel of match address?

After which, @hughabbott (Hugh Abbott) added

    image1418×632 26.2 KB
    
      
    hmmm I think i understand now

@hughabbott (Hugh Abbott) replied

    I get it now … I thought the there was some kind of reserved word for index, I did not know you set it each time to your own variable.
    
    I knew it was a very basic error … now I get it.
    
    sorry for being stupid  !
    
    and thanks for your help

@Manish540 (Manish Shettigar) replied

    You can get index of a particular row using below code, @hughabbott  
    Integer_Value = DataTable.Rows.IndexOf(row) and DataTable will be same which you pass to the For Each Row Activity.  
    Hope this may help you

So @PALKUMARI_PATEL (PALKUMARI PATEL) replied

    I found this very helpful. It's working.


{'source': 'discourse', 'url': 'https://forum.uipath.com/t/for-each-row-loop-return-row-number/296206', 'title': 'For each row loop return row number', 'views': 2928, 'has_accepted_answer': False, 'word_count': 435, 'like_count': 6, 'reply_count': 11, 'participant_count': 6, 'posts': 15, 'tags': '', 'author': '@hughabbott (Hugh Abbott)', 'participants': '@hughabbott (Hugh Abbott), @prasath17 (Guru), @NIVED_NAMBIAR (NIVED N), @Edenilson_Fernandes_dos_S (Edenilson Fernandes dos Santos), @Manish540 (Manish Shettigar), @PALKUMARI_PATEL (PALKUMARI PATEL)', 'image_url': [None], 'created_at': '2021-03-06T16:20:47.028Z', 'last_posted_at': '2022-07-03T16:05:37.884Z'}