Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Count Records & Display MsgBox

I have a unique problem I need help with. I have account numbers in column
A, the range will vary at times. Finding the last cell automatically would
be a big plus.

A
1 103456
2 34567
3 589123
4 103456
5 761234
6 34568
7 34567

I would like to search column A, counting the number of accounts, the trick,
I want to exclude the 2nd, 3rd, 4th, etc., matching records and display the
count in a MsgBox.

Based on the example above, I would like a MsgBox to display: '5 Records
were Selected'

Thanks in advance for the help.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Count Records & Display MsgBox

MyCount = WorksheetFunction.Count("A : A")

Msgbox MyCount

or in one line

MsgBox WorksheetFunction.CountA(Range("A : A"))



"Donnie Stone" wrote in message
...
I have a unique problem I need help with. I have account numbers in

column
A, the range will vary at times. Finding the last cell automatically

would
be a big plus.

A
1 103456
2 34567
3 589123
4 103456
5 761234
6 34568
7 34567

I would like to search column A, counting the number of accounts, the

trick,
I want to exclude the 2nd, 3rd, 4th, etc., matching records and display

the
count in a MsgBox.

Based on the example above, I would like a MsgBox to display: '5 Records
were Selected'

Thanks in advance for the help.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Count Records & Display MsgBox

This is based on John Walkenbach's code at:
http://j-walk.com/ss/excel/tips/tip47.htm

Sub RemoveDuplicates()
' This example is based on a tip by J.G. Hussey,
' published in "Visual Basic Programmer's Journal"

Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection

' The items are in A1:A105
Set AllCells = Range("A:A").SpecialCells(xlCellTypeConstants)

' The next statement ignores the error caused
' by attempting to add a duplicate key to the collection.
' The duplicate is not added - which is just what we want!
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a string
Next Cell

MsgBox NoDupes.Count & " records were selected"

End Sub

--
Dianne

In ,
Donnie Stone typed:
I have a unique problem I need help with. I have account numbers in
column A, the range will vary at times. Finding the last cell
automatically would be a big plus.

A
1 103456
2 34567
3 589123
4 103456
5 761234
6 34568
7 34567

I would like to search column A, counting the number of accounts, the
trick, I want to exclude the 2nd, 3rd, 4th, etc., matching records
and display the count in a MsgBox.

Based on the example above, I would like a MsgBox to display: '5
Records were Selected'



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Count Records & Display MsgBox

Dianne,

Thanks for the help, this works great. How can I change the default Title
on the MsgBox?

Regards,
Donnie

"Dianne" wrote in message
...
This is based on John Walkenbach's code at:
http://j-walk.com/ss/excel/tips/tip47.htm

Sub RemoveDuplicates()
' This example is based on a tip by J.G. Hussey,
' published in "Visual Basic Programmer's Journal"

Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection

' The items are in A1:A105
Set AllCells = Range("A:A").SpecialCells(xlCellTypeConstants)

' The next statement ignores the error caused
' by attempting to add a duplicate key to the collection.
' The duplicate is not added - which is just what we want!
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a string
Next Cell

MsgBox NoDupes.Count & " records were selected"

End Sub

--
Dianne

In ,
Donnie Stone typed:
I have a unique problem I need help with. I have account numbers in
column A, the range will vary at times. Finding the last cell
automatically would be a big plus.

A
1 103456
2 34567
3 589123
4 103456
5 761234
6 34568
7 34567

I would like to search column A, counting the number of accounts, the
trick, I want to exclude the 2nd, 3rd, 4th, etc., matching records
and display the count in a MsgBox.

Based on the example above, I would like a MsgBox to display: '5
Records were Selected'





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Count Records & Display MsgBox

From the VBA help file, here's the syntax for MsgBox:
MsgBox(prompt[, buttons] [, title] [, helpfile, context])

So to change the title:

MsgBox NoDupes.Count _
& " records were selected", _
vbInformation, "My Title"

There are a number of buttons and icons you can use on the message
box -- above I have used the vbInformation icon. You can even change
what buttons appear on the message box -- instead of OK, you can show
Yes/No or Abort/Retry/Cancel.

Check the Help for more options.

--
HTH,
Dianne

In ,
Donnie Stone typed:
Dianne,

Thanks for the help, this works great. How can I change the default
Title on the MsgBox?

Regards,
Donnie

"Dianne" wrote in message
...
This is based on John Walkenbach's code at:
http://j-walk.com/ss/excel/tips/tip47.htm

Sub RemoveDuplicates()
' This example is based on a tip by J.G. Hussey,
' published in "Visual Basic Programmer's Journal"

Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection

' The items are in A1:A105
Set AllCells = Range("A:A").SpecialCells(xlCellTypeConstants)

' The next statement ignores the error caused
' by attempting to add a duplicate key to the collection.
' The duplicate is not added - which is just what we want!
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a
string Next Cell

MsgBox NoDupes.Count & " records were selected"

End Sub

--
Dianne

In ,
Donnie Stone typed:
I have a unique problem I need help with. I have account numbers in
column A, the range will vary at times. Finding the last cell
automatically would be a big plus.

A
1 103456
2 34567
3 589123
4 103456
5 761234
6 34568
7 34567

I would like to search column A, counting the number of accounts,
the trick, I want to exclude the 2nd, 3rd, 4th, etc., matching
records and display the count in a MsgBox.

Based on the example above, I would like a MsgBox to display: '5
Records were Selected'





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Count Records & Display MsgBox

Thanks for the help.

"Dianne" wrote in message
...
From the VBA help file, here's the syntax for MsgBox:
MsgBox(prompt[, buttons] [, title] [, helpfile, context])

So to change the title:

MsgBox NoDupes.Count _
& " records were selected", _
vbInformation, "My Title"

There are a number of buttons and icons you can use on the message
box -- above I have used the vbInformation icon. You can even change
what buttons appear on the message box -- instead of OK, you can show
Yes/No or Abort/Retry/Cancel.

Check the Help for more options.

--
HTH,
Dianne

In ,
Donnie Stone typed:
Dianne,

Thanks for the help, this works great. How can I change the default
Title on the MsgBox?

Regards,
Donnie

"Dianne" wrote in message
...
This is based on John Walkenbach's code at:
http://j-walk.com/ss/excel/tips/tip47.htm

Sub RemoveDuplicates()
' This example is based on a tip by J.G. Hussey,
' published in "Visual Basic Programmer's Journal"

Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection

' The items are in A1:A105
Set AllCells = Range("A:A").SpecialCells(xlCellTypeConstants)

' The next statement ignores the error caused
' by attempting to add a duplicate key to the collection.
' The duplicate is not added - which is just what we want!
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a
string Next Cell

MsgBox NoDupes.Count & " records were selected"

End Sub

--
Dianne

In ,
Donnie Stone typed:
I have a unique problem I need help with. I have account numbers in
column A, the range will vary at times. Finding the last cell
automatically would be a big plus.

A
1 103456
2 34567
3 589123
4 103456
5 761234
6 34568
7 34567

I would like to search column A, counting the number of accounts,
the trick, I want to exclude the 2nd, 3rd, 4th, etc., matching
records and display the count in a MsgBox.

Based on the example above, I would like a MsgBox to display: '5
Records were Selected'





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
Display MsgBox when selecting a sheet Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 3 October 11th 07 03:42 PM
How to display remaining txt file which overflowed MsgBox display? EagleOne Excel Discussion (Misc queries) 1 November 2nd 06 01:10 PM
How can the count of filtered records always display? Robert Bushman Excel Worksheet Functions 1 November 2nd 05 09:11 PM
DISPLAY RANGE AT MSGBOX GUS Excel Programming 2 September 25th 03 08:38 PM
Specify font for MsgBox display? shockley Excel Programming 1 September 11th 03 01:50 PM


All times are GMT +1. The time now is 07:27 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"