Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
UB UB is offline
external usenet poster
 
Posts: 120
Default VBA code to count rows

Hi
My sheets has 9000 rows and the data is structured as

Column A Coulmn B _____Column C to H
SAM USER1
SAM USER1
SAM USER1
SAM USER2
SAM USER3
PAM USER2
PAM USER2
PAM USER3
PAM USER3
I want to look at Column A, and for each name in coulmn A, I want to count
how many times different users called in for service. The result in the above
example should be
SAM User1 User2 User3
5 3 1 1
The challange is the names in Column A and Coulmn B are always variable- no
fixed number of users and no fix number of the representatives
Can someone please advise syntax of the code
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,047
Default VBA code to count rows

have you tried a Pivot table ?
--
pleae click yes if it was helpfull
regards from Brazil
Marcelo



"ub" escreveu:

Hi
My sheets has 9000 rows and the data is structured as

Column A Coulmn B _____Column C to H
SAM USER1
SAM USER1
SAM USER1
SAM USER2
SAM USER3
PAM USER2
PAM USER2
PAM USER3
PAM USER3
I want to look at Column A, and for each name in coulmn A, I want to count
how many times different users called in for service. The result in the above
example should be
SAM User1 User2 User3
5 3 1 1
The challange is the names in Column A and Coulmn B are always variable- no
fixed number of users and no fix number of the representatives
Can someone please advise syntax of the code

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
UB UB is offline
external usenet poster
 
Posts: 120
Default VBA code to count rows

Hi Marcelo

I don't know much about Pivot tables. But I can write VBA code, if I get
some hint how the syntax should be
Thanks


"Marcelo" wrote:

have you tried a Pivot table ?
--
pleae click yes if it was helpfull
regards from Brazil
Marcelo



"ub" escreveu:

Hi
My sheets has 9000 rows and the data is structured as

Column A Coulmn B _____Column C to H
SAM USER1
SAM USER1
SAM USER1
SAM USER2
SAM USER3
PAM USER2
PAM USER2
PAM USER3
PAM USER3
I want to look at Column A, and for each name in coulmn A, I want to count
how many times different users called in for service. The result in the above
example should be
SAM User1 User2 User3
5 3 1 1
The challange is the names in Column A and Coulmn B are always variable- no
fixed number of users and no fix number of the representatives
Can someone please advise syntax of the code

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,047
Default VBA code to count rows

belive me, Pivot table is very simple and easy on this case, if you are
familiary with VB code, the pivot tables will a piece of cake.

have a nice day
--
pleae click yes if it was helpfull
regards from Brazil
Marcelo



"ub" escreveu:

Hi Marcelo

I don't know much about Pivot tables. But I can write VBA code, if I get
some hint how the syntax should be
Thanks


"Marcelo" wrote:

have you tried a Pivot table ?
--
pleae click yes if it was helpfull
regards from Brazil
Marcelo



"ub" escreveu:

Hi
My sheets has 9000 rows and the data is structured as

Column A Coulmn B _____Column C to H
SAM USER1
SAM USER1
SAM USER1
SAM USER2
SAM USER3
PAM USER2
PAM USER2
PAM USER3
PAM USER3
I want to look at Column A, and for each name in coulmn A, I want to count
how many times different users called in for service. The result in the above
example should be
SAM User1 User2 User3
5 3 1 1
The challange is the names in Column A and Coulmn B are always variable- no
fixed number of users and no fix number of the representatives
Can someone please advise syntax of the code

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default VBA code to count rows

Given your sample this should make your list starting at column I. Just
assign to a button or shape.
In this case make VERY sure that col H is EMPTY or ALL will be erased.

Sub makeuniquelist_placeformulas()
Application.ScreenUpdating = False
Range("j1").CurrentRegion.ClearContents
alr = Cells(Rows.Count, "a").End(xlUp).Row
Range("A1:a" & alr).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("I1"), Unique:=True
Range("b1:b" & alr).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("j1"), Unique:=True
lr = Cells(Rows.Count, "j").End(xlUp).Row
Range("j2:J" & lr).Copy
Range("j1").PasteSpecial Paste:=xlPasteAll, Transpose:=True
ilr = Cells(Rows.Count, "i").End(xlUp).Row
Cells(lr, "J").Resize(lr - ilr).ClearContents
'End Sub
'Sub placeformulas()
lr = Cells(Rows.Count, "i").End(xlUp).Row
Range("j2:l" & lr).Formula = _
"=IF(ISNA(SUMPRODUCT(($A$2:$A$" & alr & " =$I2)* " & _
"($B$2:$B$" & alr & "=J$1))) " & ","""",SUMPRODUCT((" & _
"$A$2:$A$" & alr & "=$I2)*($B$2:$B$" & alr & "=J$1)))"
Application.ScreenUpdating = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ub" wrote in message
...
Hi
My sheets has 9000 rows and the data is structured as

Column A Coulmn B _____Column C to H
SAM USER1
SAM USER1
SAM USER1
SAM USER2
SAM USER3
PAM USER2
PAM USER2
PAM USER3
PAM USER3
I want to look at Column A, and for each name in coulmn A, I want to count
how many times different users called in for service. The result in the
above
example should be
SAM User1 User2 User3
5 3 1 1
The challange is the names in Column A and Coulmn B are always variable-
no
fixed number of users and no fix number of the representatives
Can someone please advise syntax of the code




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default VBA code to count rows

Hi,

Assume that your data is in range A16:B18, enter SAM in cell A20 and use the
following array fomula (Ctrl+Shift+Enter)

=SUMPRODUCT(1*(FREQUENCY(IF($A$16:$A$18=$A20,IF($B $16:$B$18<"",MATCH("~"&$B$16:$B$18,$B$16:$B$18&"" ,0))),ROW($B$16:$B$18)-ROW($B$15))0))

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"ub" wrote in message
...
Hi
My sheets has 9000 rows and the data is structured as

Column A Coulmn B _____Column C to H
SAM USER1
SAM USER1
SAM USER1
SAM USER2
SAM USER3
PAM USER2
PAM USER2
PAM USER3
PAM USER3
I want to look at Column A, and for each name in coulmn A, I want to count
how many times different users called in for service. The result in the
above
example should be
SAM User1 User2 User3
5 3 1 1
The challange is the names in Column A and Coulmn B are always variable-
no
fixed number of users and no fix number of the representatives
Can someone please advise syntax of the code


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
Function to Count Zip Code Digits With Leading Zero Daren Excel Worksheet Functions 3 November 5th 08 11:37 PM
Count number of rows, where non relevant rows are hidden Pieter Excel Discussion (Misc queries) 2 November 8th 06 12:24 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM
Why does rngDataSource.Rows.Count = 65536 when worksheet Rows=95? [email protected] Excel Discussion (Misc queries) 12 July 22nd 05 12:50 PM
How do I count how many times a code appears in a column? Leo Excel Worksheet Functions 3 June 2nd 05 08:50 PM


All times are GMT +1. The time now is 05:29 AM.

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"