PDA

View Full Version : The sampler should give transactions of



pramoc
04-05-2007, 03:02 AM
hi
column b has the operator name.
column k has currency name.
i need report which has

1)at least 10% of the number of transactions by each operator
2)at least 10% of the value in each currency's total.
it should be atleast 10% minor variation is not a problem at all

Bob Phillips
04-05-2007, 03:24 AM
Don't know about anyone else, but that spec is sketchy to me to put it mildly.

At least 10%, so 11, 25,33, 40, 75, 100%?

pramoc
04-05-2007, 03:27 AM
it should be atleast 10% minor variation is not a problem at all.
thnk for concern

pramoc
04-05-2007, 03:53 AM
Hi XLD..

Thanks for ur time and effort..

Let me bbe bit descriptive abt the issue.

As you have seen the worksheet that contains data basis which I need the report.

What I need is that for every operator I need 10% of total samples into another sheet. say for instance Sheet1 contains 40 records of "Andrew" so, what I need is that the total report will contain atleast 10% of Andrew's data..

Second condition..

Every operator enters data that may have different currency values like US Dollar or Euro (Pls see cur column for sample). Now my final report shud contains 10% record of every operator and 10% each currency's value which we wud get from the data...

Pls help ..:think:

Shane
04-09-2007, 12:30 AM
somebody pls help

mdmackillop
04-09-2007, 07:38 AM
Here's code for the Operators. Currencies can be dealt with in similar fashion and duplicates deleted.
Option Explicit

Dim LR As Long

Sub Macro1()
Dim op, Rws As Long, Found As Long
Dim Rng As Range, Tgt As Range

Application.ScreenUpdating = False
LR = Cells(Rows.Count, 1).End(xlUp).Row
Set Rng = Range("A1", "P" & LR)

'Add helper columns
Columns("B:C").Insert
Range("B1") = "Order"
Range("C1") = "Random"
Range("B2").Select

'Add order reference
With Range("B2")
.Value = 1
.NumberFormat = "General"
.AutoFill Destination:=Range("B2:B" & LR)
End With
Range("B2:B" & LR).DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1
'Add random reference
With Range("C2:C" & LR)
.FormulaR1C1 = "=RC[1] & ""-"" &RAND()"
.Copy
.PasteSpecial Paste:=xlPasteValues
End With
Range("A1").Select

'Sort randomised data
Columns("A:P").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

'Create list of operatives; process in turn
For Each op In Operatives
'Find first occurrence
Found = Columns(4).Find(What:=op, after:=Range("D1")).Row
'Count occurrences; calculate 10%
Rws = Application.WorksheetFunction.CountIf(Columns(4), op)
Rws = Int(Rws / 10) + 1
'Copy from first found for 10% of rows
Set Tgt = Sheets(2).Cells(Rows.Count, 1).End(xlUp).Offset(1)
Cells(Found, 1).Resize(Rws, 16).Copy Tgt
Next

'Resort to original order
Rng.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

'Delete added columns
Columns(26).Delete
Sheets(1).Columns("B:C").Delete
Sheets(2).Columns("B:C").Delete

Application.ScreenUpdating = True

End Sub
Function Operatives() As Variant
Range("D1:D" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"Z1"), Unique:=True
Range("Z2", Range("Z2").End(xlDown)).Interior.ColorIndex = 6
Operatives = Range("Z2", Range("Z2").End(xlDown))
End Function