View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Selecting varying length range


You should always post your coding efforts for comments and suggestions. To
find the last row use the longest column this. Then refer to it instead of
the row in the constant

lastrow=cells(rows.count,"a").end(xlup).row
range("a2:a22")
range("a2:a" & lastrow)

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Nan" wrote in message
...
I have 22 different files for which I want to use the same procedure (with
few modifications). The procedure opens a specific file (different for
each
file containing the macro), inserts columns, inserts formulas, and then
fills
the formulas down to the last cell in it's column. (Maunally I would
simply
double-click the autofill handle and Excel would copy down to the last
cell
based on the column to the left.) When I record the actions, the ending
cell
is absolute, so I've had to go into each of the 22 modules and manually
enter
the ending cells for each file. I know there's a way to set the last cell
I
need as a variable, but even after reading other posts on this subject I
can't get it to work.

Thanks to all for your suggestions.
--
TIA, Nan