talkingtang,
BTW, just a quick and dirty example. Let me know if you need more refinement.
Regards,
Justin
Main Topics
Browse All TopicsDear all,
Currently I hav a worksheet that contains data. All I have to do is counting the amount of rows and columns of the table. How can I gonna to do it writting VBE code? ( assume that the amount of entire row is i and the amount of entire columns is j ). After that I will display it into a message box. The message box is like this:
strmsg = "rows =" & i & "columns =" & j
MsgBox "strmsg"
Hope somebody can help me. Thanks!
Rdgs,
talkingtang
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Dear JustinCase2,
I have one Q to ask. According to your coding, what is selected? Are you mean that first I have to select the table then run the coding? Is there any way that will perform the task when we don't select the table? If I chage the "Selection" into "ActiveSheet", it will gives me rows:65536, and colums:256, but this is not I wan.
talkingtang
talkingtang,
Try this:
Option Explicit
Sub DisplayRowColumnCount()
Dim strMsg As String
Dim lngRow As Long
Dim intCol As Integer
Range("A1").Select
ActiveCell.SpecialCells(xl
lngRow = ActiveCell.Row
intCol = ActiveCell.Column
strMsg = "rows: " & lngRow & " columns: " & intCol
MsgBox strMsg
End Sub
Hope this helps.
Thanks for the grade talkingtang.
Excel can get a bit muddled on the Last Cell and UsedRange at times, see http://j-walk.com/ss/excel
Thanks for the pointer to my response Justin
Cheers
Dave
Business Accounts
Answer for Membership
by: JustinCase2Posted on 2003-08-20 at 18:28:30ID: 9192539
talkingtang,
Use the count method, like:
Sub test()
Dim str As String
str = "rows: " & Selection.Rows.Count & " columns: " & Selection.Columns.Count
x = MsgBox(str, vbOKOnly)
End Sub
Justin