ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   EOF general usage (https://www.excelbanter.com/excel-programming/401824-eof-general-usage.html)

pvdalen[_2_]

EOF general usage
 
Howdy,

I have a sheet in which I want to run a macro to cycle through the sheet and
perform some operations. Well, I guess that's pretty obvious......anyway,
the number of rows will not be the same from use to use, so I wanted to loop
the file with

Do While Not EOF

but, I get an "Argument not optional" message. I was hoping that since the
data to be parsed is in the sheet itself that I wouldn't have to open it as a
file or a recordset and use EOF as a function of those, but it looks like I'm
wrong? Can someone educate me, please?

Oh, the reason I'm shying away from
Cells(Rows.Count, column).End(xlUp).Row
is that it's not clear what the lowest limit of each column might be. I
just might end up using that on a few columns and going with the lowest
number....

Thanks very much.


Hemant_india[_2_]

EOF general usage
 
try this
dim rng as range
set rng=activesheet.usedrange
for n= 1 to rng.rows.count
do your stuff
next

--
hemu


"pvdalen" wrote:

Howdy,

I have a sheet in which I want to run a macro to cycle through the sheet and
perform some operations. Well, I guess that's pretty obvious......anyway,
the number of rows will not be the same from use to use, so I wanted to loop
the file with

Do While Not EOF

but, I get an "Argument not optional" message. I was hoping that since the
data to be parsed is in the sheet itself that I wouldn't have to open it as a
file or a recordset and use EOF as a function of those, but it looks like I'm
wrong? Can someone educate me, please?

Oh, the reason I'm shying away from
Cells(Rows.Count, column).End(xlUp).Row
is that it's not clear what the lowest limit of each column might be. I
just might end up using that on a few columns and going with the lowest
number....

Thanks very much.



All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com