Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default For FARAZ QURESHI - Column Entry Counts

The board is not operating properly, cannot find or reply to your request to:
select column, count & report items in it, move to next column based on user
choice and repeat - but here is code that I believe will do what you want. I
hope so, and I hope you see this message.

Sub CountEntriesInAColumn()
Dim lastUsedColumn As Long
Dim lastUsedRow As Long
Dim currentColumnArea As Range
Dim itemCount As Long
Dim continueFlag As Integer

lastUsedColumn = ActiveCell.SpecialCells(xlLastCell).Column
lastUsedRow = ActiveCell.SpecialCells(xlLastCell).Row
continueFlag = vbYes ' initialize
Do While continueFlag = vbYes
Cells(1, ActiveCell.Column).Activate
Set currentColumnArea = _
ActiveSheet.Range(ActiveCell.Address & ":" & _
Cells(lastUsedRow, ActiveCell.Column).Address)
itemCount = Application.WorksheetFunction. _
CountA(currentColumnArea)
'test if this is the last column
If ActiveCell.Column = lastUsedColumn Then
'either at last used column or to the right of it
MsgBox "This column has " & _
itemCount & " entries in it." & vbCrLf _
& "It is the last used column.", vbOKOnly, _
"Column Entry Count"
continueFlag = vbNo ' set flag to stop loop
Else
'more columns to examine
continueFlag = MsgBox("This column has " & _
itemCount & " entries in it." & vbCrLf _
& "Do you want to continue?", vbYesNo, _
"Column Entry Count")
If continueFlag = vbYes Then
'move to next column
ActiveCell.Offset(0, 1).Activate
End If
End If
Loop
MsgBox "Operation Complete"
End Sub

Reply
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
average daily counts to weekly counts Dave Excel Discussion (Misc queries) 0 June 17th 08 06:24 PM
Auto entry of data based on entry of text in another column or fie Judy Rose Excel Discussion (Misc queries) 2 May 21st 08 01:14 PM
eliminate data entry of counts by state redhead New Users to Excel 3 February 2nd 08 04:02 AM
Column Counts Brurobiney Excel Discussion (Misc queries) 1 March 15th 07 09:07 PM
Looking for a Function which counts the repeatition of text in a column [email protected] Excel Worksheet Functions 1 February 16th 06 03:41 PM


All times are GMT +1. The time now is 02:22 PM.

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

About Us

"It's about Microsoft Excel"