#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Counting entries

Hi,

I'm trying to count zip codes in a dynamic fashion. Is there a
function which will identify what zips are present assigning each 2
cells as follows:

A1 B1 C1 D1
88001 12
A2 B2 C2 D2
88002 48
A3 B3 C3 D3
88005 17

So basically figure out what is there and how many times it occures in
a column, I know I can set up a COUNTIF function, but I don't want to
have to do that each time I ad a zip and I only want the spreadsheet so
large... I'm sure I've missed someting obvious, but can't for the life
of me find it.

Thanks,

Byron

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Counting entries


How about a Pivot Table?

HTH!


--
ExcelChampion
------------------------------------------------------------------------
ExcelChampion's Profile: http://www.officehelp.in/member.php?userid=5096
View this thread: http://www.officehelp.in/showthread.php?t=1262228

Posted from - http://www.officehelp.in

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Counting entries

If all of the zips will be entered into column A, you could right click on
your sheet tab and paste this code into the code window to add the Countif
function as you go and remove the countif function as zips are deleted.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range

If Target.Column < 1 Or Target.Columns.Count 1 _
Then Exit Sub

Application.EnableEvents = False

For Each rngCell In Target.Cells
If Not IsEmpty(rngCell) Then
rngCell(1, 2).Formula = "=Countif(A:A," _
& rngCell.Address(False, False) & ")"
Else: rngCell(1, 2).ClearContents
End If
Next rngCell

Application.EnableEvents = True

End Sub

"Dos Equis" wrote:

Hi,

I'm trying to count zip codes in a dynamic fashion. Is there a
function which will identify what zips are present assigning each 2
cells as follows:

A1 B1 C1 D1
88001 12
A2 B2 C2 D2
88002 48
A3 B3 C3 D3
88005 17

So basically figure out what is there and how many times it occures in
a column, I know I can set up a COUNTIF function, but I don't want to
have to do that each time I ad a zip and I only want the spreadsheet so
large... I'm sure I've missed someting obvious, but can't for the life
of me find it.

Thanks,

Byron


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Counting entries

JMB,

All zips go in column K so I think I should change the code to reflect:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range

If Target.Column < 11 Or Target.Columns.Count 11 _
Then Exit Sub

Application.EnableEvents = False

For Each rngCell In Target.Cells
If Not IsEmpty(rngCell) Then
rngCell(1, 2).Formula = "=Countif(A:A," _
& rngCell.Address(False, False) & ")"
Else: rngCell(1, 2).ClearContents
End If
Next rngCell

Application.EnableEvents = True

End Sub

I'm assuming thet (rngcell) is the range of cells I would want the zips
stored in such as W:W Would you please identify anything else I would
need to alter? Thank you,


Byron

JMB wrote:
If all of the zips will be entered into column A, you could right click on
your sheet tab and paste this code into the code window to add the Countif
function as you go and remove the countif function as zips are deleted.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range

If Target.Column < 1 Or Target.Columns.Count 1 _
Then Exit Sub

Application.EnableEvents = False

For Each rngCell In Target.Cells
If Not IsEmpty(rngCell) Then
rngCell(1, 2).Formula = "=Countif(A:A," _
& rngCell.Address(False, False) & ")"
Else: rngCell(1, 2).ClearContents
End If
Next rngCell

Application.EnableEvents = True

End Sub

"Dos Equis" wrote:

Hi,

I'm trying to count zip codes in a dynamic fashion. Is there a
function which will identify what zips are present assigning each 2
cells as follows:

A1 B1 C1 D1
88001 12
A2 B2 C2 D2
88002 48
A3 B3 C3 D3
88005 17

So basically figure out what is there and how many times it occures in
a column, I know I can set up a COUNTIF function, but I don't want to
have to do that each time I ad a zip and I only want the spreadsheet so
large... I'm sure I've missed someting obvious, but can't for the life
of me find it.

Thanks,

Byron



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Counting entries

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range

If Target.Column < 11 Or Target.Columns.Count 1 _
Then Exit Sub

Application.EnableEvents = False

For Each rngCell In Target.Cells
If Not IsEmpty(rngCell) Then
rngCell(1, 13).Formula = "=Countif(K:K," _
& rngCell.Address(False, False) & ")"
Else: rngCell(1, 2).ClearContents
End If
Next rngCell

Application.EnableEvents = True

End Sub



rngCell is a placeholder for the For/Next loop.

For Each rngCell In Target.Cells


which is read as
"For Each *Item* In *Some Collection*

It loops through each cell in the Target Range (Target refers to whatever
cell was changed - which is why we test the column number to see if Target is
column K (or 11)). Whatever cell the loop is processing is referred to as
rngCell (a name that I made up) in the code inside the loop.



"Dos Equis" wrote:

JMB,

All zips go in column K so I think I should change the code to reflect:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range

If Target.Column < 11 Or Target.Columns.Count 11 _
Then Exit Sub

Application.EnableEvents = False

For Each rngCell In Target.Cells
If Not IsEmpty(rngCell) Then
rngCell(1, 2).Formula = "=Countif(A:A," _
& rngCell.Address(False, False) & ")"
Else: rngCell(1, 2).ClearContents
End If
Next rngCell

Application.EnableEvents = True

End Sub

I'm assuming thet (rngcell) is the range of cells I would want the zips
stored in such as W:W Would you please identify anything else I would
need to alter? Thank you,


Byron

JMB wrote:
If all of the zips will be entered into column A, you could right click on
your sheet tab and paste this code into the code window to add the Countif
function as you go and remove the countif function as zips are deleted.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngCell As Range

If Target.Column < 1 Or Target.Columns.Count 1 _
Then Exit Sub

Application.EnableEvents = False

For Each rngCell In Target.Cells
If Not IsEmpty(rngCell) Then
rngCell(1, 2).Formula = "=Countif(A:A," _
& rngCell.Address(False, False) & ")"
Else: rngCell(1, 2).ClearContents
End If
Next rngCell

Application.EnableEvents = True

End Sub

"Dos Equis" wrote:

Hi,

I'm trying to count zip codes in a dynamic fashion. Is there a
function which will identify what zips are present assigning each 2
cells as follows:

A1 B1 C1 D1
88001 12
A2 B2 C2 D2
88002 48
A3 B3 C3 D3
88005 17

So basically figure out what is there and how many times it occures in
a column, I know I can set up a COUNTIF function, but I don't want to
have to do that each time I ad a zip and I only want the spreadsheet so
large... I'm sure I've missed someting obvious, but can't for the life
of me find it.

Thanks,

Byron




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
Counting Unique Entries SouthCarolina Excel Discussion (Misc queries) 7 April 14th 06 01:18 PM
counting date entries by month & year Di Excel Worksheet Functions 7 August 24th 05 08:39 PM
Counting Duplicate Entries No_name Excel Worksheet Functions 1 July 18th 05 04:01 PM
Counting unique entries in column A but only if specific values appear in columns B and C markx Excel Worksheet Functions 1 February 10th 05 11:52 AM
counting entries between two dates? Todd Excel Worksheet Functions 7 November 1st 04 11:07 PM


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