LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default List items based on the count given

Hi,

Am Wed, 12 Mar 2014 07:54:39 +0000 schrieb CS Chia:

I have a table that list items and the frequency for each item, as shown
below
Item frequency
A 1
B 3
C 4
D 1
E 0

Base on the above, the system should populate a list base on the above
Expected result is:

Item Count
A 1
B 1
B 2
B 3
C 1
C 2
C 3
C 4
D 1


your table in sheet1. The following macro writes the expected table in
sheet2:

Sub ArrangeTable()
Dim arrIn As Variant
Dim LRow As Long
Dim i As Long, j As Long, n As Long

LRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
arrIn = Range("A2:B" & LRow)
n = 1
With Sheets("Sheet2")
For i = LBound(arrIn) To UBound(arrIn)
If arrIn(i, 2) 0 Then
For j = 1 To arrIn(i, 2)
.Cells(n, 1) = arrIn(i, 1)
.Cells(n, 2) = j
n = n + 1
Next
End If
Next
End With
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
 
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
How do I count items based upon two separate values? Southwestern Eric Excel Worksheet Functions 1 June 23rd 07 12:40 AM
2 conditions needed to check and count of items based on that Vijay Excel Worksheet Functions 2 May 3rd 07 10:21 PM
How to count and group items in a list depending on size of list? Simon Lloyd[_859_] Excel Programming 3 August 13th 06 12:18 AM
How to count items in a list and group depending on size of list? Simon Lloyd[_712_] Excel Programming 5 April 28th 06 12:14 AM
Count items on the list dannyboy213 Excel Discussion (Misc queries) 5 February 2nd 06 08:12 PM


All times are GMT +1. The time now is 11:28 AM.

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

About Us

"It's about Microsoft Excel"