LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Areas, rows and colums

I am trying to write a code to help analyze data and need to determine the
number of areas, rows and columns in each worksheet that is accessed.
Based on help searches, I have written the following crude code but it does
not work for all worksheets. Of great concern is that the
"selection.Areas.count" does not give me anything more than "one area". The
Rows and Columns count property gives various answers depending on the layout
of the worksheet. Does anyone have any suggestions?

Code:
Sub Rows_Cols()
' procedure counts the number of rows and columns
Dim nAreaCnt As Integer 'Determines if the sheet is formated properly for
analysis
Dim nRowCnt As Integer 'Stores the number of Rows in the sheet
Dim nCowCnt As Integer 'Stores the number of Columns in the sheet

nAreaCnt = Selection.Areas.Count
MsgBox "Number of Areas " & nAreaCnt
If nAreaCnt = 1 Then
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
nColCnt = Selection.Columns.Count
nRowCnt = Selection.Rows.Count
MsgBox "Number of Rows " & nRowCnt
MsgBox "Number of columns " & nColCnt
Else
MsgBox "Worksheet has empty rows or columns. Please fill sheet"
End If

End Sub



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
rows and colums lizfox Excel Discussion (Misc queries) 2 November 20th 09 07:04 PM
Inserting Rows in multiple areas jlclyde Excel Discussion (Misc queries) 1 January 24th 08 08:18 PM
How do change rows to colums AND columns to rows Colleen A Excel Discussion (Misc queries) 7 December 30th 05 12:40 AM
Print few rows with many colums so that rows wrap on printed pages usfgradstudent31 Excel Discussion (Misc queries) 1 October 20th 05 02:39 PM
How do I name the colums and rows? Cin3 New Users to Excel 5 January 5th 05 11:09 PM


All times are GMT +1. The time now is 12:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"