#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Find the variance

Hi,

i have few thousand column of sales' DO list, but cutomer's received qty and
our sales qty doesn't match by 11444 qty.

From the sales data, could i know which DO can make up this qty 11444. by
using any formula?

thanks in advance!!!

lawrence
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Find the variance

Tushar,

thanks for your great help, but the template does work perfectly. may i can
elaborate more as below for your better understanding

DO# Delivered qty
1a 123
2a 234
3a 567
4a 123
5a 245

so my target is 246 qty, can i using formula so that i can know which DO can
make up 246 qty? answer: 1a + 4a

Lawrence


"Tushar Mehta" wrote:

In article ,
says...
Hi,

i have few thousand column of sales' DO list, but cutomer's received qty and
our sales qty doesn't match by 11444 qty.

From the sales data, could i know which DO can make up this qty 11444. by
using any formula?

thanks in advance!!!

lawrence

If you are looking to match only complete sales, you should be able to
adapt the idea at
Find a set of amounts that match a target value
http://www.tushar-mehta.com/excel/te...ues/index.html

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 527
Default Find the variance



"Lawrence" wrote:

Tushar,

thanks for your great help, but the template does work perfectly. may i can
elaborate more as below for your better understanding

DO# Delivered qty
1a 123
2a 234
3a 567
4a 123
5a 245

so my target is 246 qty, can i using formula so that i can know which DO can
make up 246 qty? answer: 1a + 4a


Lawrence

I have not seen Tusha's template but it seems that you want to find
combinations that reach a target i.e. singles, doubles et al. This takes
forever, especially when you look for five combinations or more and requires
a macro.

The following procedures examines data in column B and enters the
combinations in columns D and E, also the target figure is placed in A7.

I would copy your data into a blank workbook before trying this, it will
delete the information in columns D and E (and any adjacent columns) - make a
cup of coffee while you wait!


I'll send you a copy of the test sheet if you want to see it. mail at
peter_atherton at hotmail dot com

regards
Peter

Copy the following into a VB module

Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, x As Double, z As Integer
Dim row As Long, count As Long, lr As Long
Dim r As Long, col As Integer, rng

Private Sub getRange()
x = InputBox("Enter the target Number", "Target Sums", 0#)
r = ActiveCell.row
col = ActiveCell.Column
Range("A7") = x
With ActiveSheet
rng = Cells(r, col).Address
End With
y = InputBox("Enter the range", "Enter Data range", rng)

Range(y).Select
lr = Selection.Rows.count
ActiveCell.Select

End Sub

Sub unit()
Dim startTime As Date, EndTime As Date, TimeTaken As Date
Range("D3").CurrentRegion.ClearContents
getRange
Application.StatusBar = "Combinations Running! Please wait...."
Application.ScreenUpdating = False
row = 3: count = 0
'------Remove the next line when ready------
startTime = Now
'--------------------
For i = 1 To lr
y = CCur(Cells(i, 2))
If y = CCur(x) Then
'this line can be remmed out so sums are not shown
Cells(row, 4) = Cells(i, 2)
' alternatively, this line showing cells can be remmed out
Cells(row, 5) = Cells(i, 2).Address(RowAbsolute:=False, _
columnabsolute:=False)
row = row + 1: count = count + 1
End If
Next i
Doubles
Columns("D:E").EntireColumn.AutoFit
Application.ScreenUpdating = True
'--------Remove these lines when ready---------
EndTime = Now
TimeTaken = EndTime - startTime
MsgBox TimeTaken, vbInformation, "Time Taken to complete procedure"
MsgBox count, vbInformation, "Total Number of combinations"
'---------------------------------------------
Application.StatusBar = ""
End Sub

Private Sub Doubles()

row = 3
For i = 1 To lr - 1
For z = lr To 2 Step -1
y = CCur(Cells(i, 2) + Cells(z, 2))
If y = CCur(x) And i < z And Cells(i, 2) < 0 Then
'this line can be remmed out so sums are not shown
Cells(row, 4) = Cells(i, 2) & "+" & Cells(z, 2)
' alternatively, this line showing cells can be remmed out
Cells(row, 5) = Cells(i, 2).Address(RowAbsolute:=False, _
columnabsolute:=False) & "+" & Cells(z, 2).Address(RowAbsolute:=False,
columnabsolute:=False)
row = row + 1: count = count + 1
End If
Next
Next
Trebles
End Sub
Private Sub Trebles()

For i = 1 To lr - 2
For j = 2 To lr - 1
For z = lr To 2 Step -1
y = CCur(Cells(i, 2) + Cells(j, 2) + Cells(z, 2))
If y = CCur(x) And _
i < j And j < z And Cells(i, 2) < 0 And Cells(j, 2) < 0 And
Cells(z, 2) < 0 Then
' this line can be remmed out so sums are not shown
Cells(row, 4) = Cells(i, 2) & "+" & Cells(j, 2) & "+" & Cells(z, 2)
' alternatively, this line showing cells can be remmed out
Cells(row, 5) = Cells(i, 2).Address(RowAbsolute:=False, _
columnabsolute:=False) & "+" & Cells(j,
2).Address(RowAbsolute:=False, _
columnabsolute:=False) & "+" & Cells(z,
2).Address(RowAbsolute:=False, columnabsolute:=False)
row = row + 1: count = count + 1
End If
Next z
Next j
Next i
quads
End Sub

Private Sub quads()
For i = 1 To lr - 3
For j = 2 To lr - 2
For k = 3 To lr - 1
For z = lr To 3 Step -1
y = CCur(Cells(i, 2) + Cells(j, 2) + Cells(k, 2) + Cells(z, 2))
If y = CCur(x) And _
i < j And j < k And k < z And Cells(i, 2) < 0 And Cells(j, 2) <
0 _
And Cells(k, 2) < 0 And Cells(z, 2) < 0 Then
'this line can be remmed out so sums are not shown
Cells(row, 4) = Cells(i, 2) & "+" & Cells(j, 2) & "+" & Cells(k,
2) _
& "+" & Cells(z, 2)
' alternatively, this line showing cells can be remmed out
Cells(row, 5) = Cells(i, 2).Address(RowAbsolute:=False,
columnabsolute:=False) _
& "+" & Cells(j, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(k, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(z, 2).Address(RowAbsolute:=False,
columnabsolute:=False)
row = row + 1: count = count + 1
End If
Next z
Next k
Next j
Next i
Quins
End Sub
Private Sub Quins()
' The procedure really slows at this point
' to stop this macro running you need to rem it out;
' just type an apostrophe before quins in the last macro
' second line from end
For i = 1 To lr - 4
For j = 2 To lr - 3
For k = 3 To lr - 2
For l = 4 To lr - 1
For z = lr To 4 Step -1
y = CCur(Cells(i, 2) + Cells(j, 2) + Cells(k, 2) + Cells(l, 2) +
Cells(z, 2))
If y = CCur(x) And _
i < j And j < k And k < l And l < z And Cells(i, 2) < 0 And
Cells(j, 2) < 0 _
And Cells(k, 2) < 0 And Cells(l, 2) < 0 And Cells(z, 2) < 0
Then
' this line can be remmed out so sums are not shown
Cells(row, 4) = Cells(i, 2) & "+" & Cells(j, 2) & "+" &
Cells(k, 2) _
& "+" & Cells(l, 2) & "+" & Cells(z, 2)
' alternatively, this line showing cells can be remmed out
Cells(row, 5) = Cells(i, 2).Address(RowAbsolute:=False,
columnabsolute:=False) _
& "+" & Cells(j, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(k, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(l, 2).Address(RowAbsolute:=False,
columnabsolute:=False) _
& "+" & Cells(z, 2).Address(RowAbsolute:=False,
columnabsolute:=False)

row = row + 1: count = count + 1
End If
Next z
Next l
Next k
Next j
Next i
sextet
End Sub
Private Sub sextet()
For i = 1 To lr - 5
For j = 2 To lr - 4
For k = 3 To lr - 3
For l = 4 To lr - 2
For m = 5 To lr - 1
For z = lr To 5 Step -1
y = CCur(Cells(i, 2) + Cells(j, 2) + Cells(k, 2) + Cells(l, 2) + _
Cells(m, 2) + Cells(z, 2))
If y = CCur(x) And i < j And j < k And k < l And l < m And m < z _
And Cells(i, 2) < 0 And Cells(j, 2) < 0 _
And Cells(k, 2) < 0 And Cells(l, 2) < 0 And Cells(z, 2) < 0
Then
' this line can be remmed out so sums are not shown
Cells(row, 4) = Cells(i, 2) & "+" & Cells(j, 2) & "+" &
Cells(k, 2) _
& "+" & Cells(l, 2) & "+" & Cells(m, 2) & "+" & Cells(z, 2)

Cells(row, 5) = Cells(i, 2).Address(RowAbsolute:=False,
columnabsolute:=False) _
& "+" & Cells(j, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(k, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(l, 2).Address(RowAbsolute:=False,
columnabsolute:=False) & _
"+" & Cells(m, 2).Address(RowAbsolute:=False,
columnabsolute:=False) _
& "+" & Cells(z, 2).Address(RowAbsolute:=False,
columnabsolute:=False)

row = row + 1: count = count + 1
End If
Next z
Next m
Next l
Next k
Next j
Next i

End Sub


'============= End of VB 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
Find Variance DEE Excel Worksheet Functions 2 November 28th 06 07:30 PM
Variance FreddieP Excel Discussion (Misc queries) 5 September 28th 06 01:41 PM
variance % karibug Excel Worksheet Functions 5 June 14th 06 10:54 PM
Pivot Tables - Variance and Variance % PJS Excel Discussion (Misc queries) 2 January 18th 06 03:12 AM
Pivot Tables - Variance and % Variance fields CraigS Excel Discussion (Misc queries) 5 January 6th 05 12:22 AM


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