To get the row number.

  • Thread starter Thread starter Shaijuzacharia
  • Start date Start date
S

Shaijuzacharia

Hi,

I have got an Excel file with data. A word "total" is repeated in two
different row but same column.
I want to get the row number of the of the occurence of the word
stored to a variable.
That is I have two loops where i want to use the row ID of the 1st
occurence of the word "total" and in the second loop I wanted to use
the row ID of the second occurence of the word.

Thanks,
Shaiju
 
Hi,
Use :
row1 = Columns(1).Find("total", , , xlWhole).Row
for the first occurence, and :
row2 = Columns(1).Find("total", [A65000], , xlWhole, , xlPrevious).Row
for the last one.
You'll have to change the column number according to your needs.
Regards.
Daniel
 
Hi,
Use :
row1 = Columns(1).Find("total", , , xlWhole).Row
for the first occurence, and :
row2 = Columns(1).Find("total", [A65000], , xlWhole, , xlPrevious).Row
for the last one.
You'll have to change the column number according to your needs.
Regards.
Daniel


I have got an Excel file with data. A word "total" is repeated in two
different row but same column.
I want to get the row number of the of the occurence of the word
stored to a variable.
That is I have two loops where i want to use the row ID of the 1st
occurence of the word "total" and in the second loop I wanted to use
the row ID of the second occurence of the word.
Thanks,
Shaiju- Hide quoted text -

- Show quoted text -

Daniel,

Thank yoy very much.
But can I use this in a macro?

Shaiju
 
Hi,
Use :
row1 = Columns(1).Find("total", , , xlWhole).Row
for the first occurence, and :
row2 = Columns(1).Find("total", [A65000], , xlWhole, , xlPrevious).Row
for the last one.
You'll have to change the column number according to your needs.
Regards.
Daniel


I have got an Excel file with data. A word "total" is repeated in two
different row but same column.
I want to get the row number of the of the occurence of the word
stored to a variable.
That is I have two loops where i want to use the row ID of the 1st
occurence of the word "total" and in the second loop I wanted to use
the row ID of the second occurence of the word.
Thanks,
Shaiju- Hide quoted text -

- Show quoted text -

Daniel,

Thank yoy very much.
But can I use this in a macro?

Shaiju

Yes, it is intented for. If you have a doubt, post your code.
Daniel
 
Back
Top