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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping thru rows in excel 1

Status
Not open for further replies.

dokken

Programmer
Mar 7, 2001
61
US
I am trying to create a macro that will take the data in an existing spreadsheet and apply a grid around all the rows and columns with data in them. I have used the macro recorder to select cells and apply the format I want. What I don't know how to do is programmatically figure out how many rows and columns are in the spreadsheet. Does anybody know how I would do this? I have tried the Selection.CurrentRegion.Select but it skips a column if there is a blank column of data.

Paul

 
The last row in a spreadsheet which contains data can
be found with the following statement...
lastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row

The last column of data can be found with the statement...
lastColumn = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
 
This was just the answer I was looking for. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top