Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macros, excel and formatting variable cells

Status
Not open for further replies.

daveonion

Programmer
Aug 21, 2002
359
GB
I need to format cells in excel using a macro. The problem is that sometimes the amount of rows will differ, so for instance one time it might be 100 rows another time it might be 2000. However if i select the whole column then obviously it grabs 67000 cells so when printing it will print a 1000 pages instead of the needed 2.
I need the code which will select only the needed cells,
any ideas
Thanks
 
Cells(1, 1).Select
Set currRegion = ActiveCell.CurrentRegion
numRows = currRegion.Rows.Count
MsgBox numRows

thats one way of doing it, but this depends on you not having any blank fields in column one,,
 
here is another one

MsgBox ActiveCell.Address
MsgBox ActiveCell.End(xlToRight).Address
MsgBox ActiveCell.End(xlDown).Address

which doesnt depend on blank lines...i dont think

mrmovie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top