V
Vikram Dhemare
Complex Sum, Reqd. codes.
Hi,
I am trying to develop a report, which provides the current inventory
status. There are four sheets named Recpt, Issue, Despatches (as databse) &
StockList (as Summery Statement).
The users are putting the inputs in recpt as receipt of material as per the
consignments received in other words 'Goods recd Notes'.
The sheet is having coulmns like : Doc. No., Date, Part No., Descrption,
Quantity, Supplier name, Remarks.
Second sheet i.e Issue: It is basically for issueance of material to
production line having columns like : Doc. No. (issue slip no.), Date, Part
No. Description, Quantity Issued, Remarks.
The third sheet is Despatches, despatches is being imported from access
database, the date field is in "DD/MM/YYYY HH:MM:SS" format. (here the
evalute funtion doesn't work).
The fourth sheet is the summery sheet where the unique item list (standard
& constant) is there having columns: Part No., Description, Stock Quanity.
Now I am trying to generate the stocks on button click on certain conditions
say if user want to see the stock for any particular date then user have to
give the date via input box.
If user gives the date in input box then the code should search the value
for particular item satisfying the date contions like <=, in recpt, issue as
well as in despatches & put the
result value in summery sheet corresponding row. (All the entries in
database may have repeated, say one part may have recd twice / trice or so
on), then the variable should
store the sum of recpt, issue & despatches.
It is the simple arithmatic formula i.e: Stock as on User defined date =
Reciepts less than particular date)-(Issue less than user defined date +
despatches less than user defined date)
I have tried this by applying application.evaluate(sumproduct funtion). But
the data is huge caused slowed the report geretating process. Is there any
other solution for such report.
I have tried the following codes & getting the results but this is slowed
down the process.
Option Explicit
Dim myCell As Range
Sub Do_Summery()
Dim RequestedDate As Date
Dim ans, ans1, ans2, ans3 As Variant
RequestedDate = InputBox("Enter the report date in DD/MM/YYYY format ",
Format(Now, "DD/MM/YYYY"))
Worksheets("StockList").Range("E1") = "Stock as on " &
Format(RequestedDate, "dd/mm/yyyy")
Application.Calculation = xlCalculationManual
For Each myCell In Worksheets("StockList").Range("InputStockRng")
ans = Application.Evaluate("=sumproduct(('Recpt'!F2:F65500= """ _
& myCell.Value & """ )*('Recpt'!B2:B65500<=" &
CLng(RequestedDate) & ")*('Recpt'!G2:G65500))")
ans1 =
Application.Evaluate("=sumproduct(('Issue'!D265500= """ _
& myCell.Value & """ )*('Issue'!B2:B65500<=" &
CLng(RequestedDate) & ")*('Issue'!F2:F65500))")
'ans2 = Application.Evaluate("=sumproduct(('Desp'!E2:E65500= """ _
& myCell.Value & """ )*(int('Desp'!B2:B65500)=" &
CLng(RequestedDate) & "),('Desp'!J2:J65500))")
ans3 = ans1 + ans2
With myCell
.Offset(0, 3).Value = ans - ans3
End With
Next myCell
Set myCell = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub
Can we store variable like m = sum(if(('Recptuptolastfilledrow= """ _
& myCell.Value & """ )*(Recptuptolastfilledrow<=" &
CLng(RequestedDate) & ")*(Recptuptolastfilledrow))")
and so on. This may run the code faster & provide the desired report in a
fraction of seconds.
Further can we change the format of date field while importing the data into
excel from access. Such as with recordset(Field date)=format("DD/MM/YYYY") &
then copy the recodset to excel file.
Hope, I expressed it correctly. Any help in this regard will be highly
appreciated.
Hi,
I am trying to develop a report, which provides the current inventory
status. There are four sheets named Recpt, Issue, Despatches (as databse) &
StockList (as Summery Statement).
The users are putting the inputs in recpt as receipt of material as per the
consignments received in other words 'Goods recd Notes'.
The sheet is having coulmns like : Doc. No., Date, Part No., Descrption,
Quantity, Supplier name, Remarks.
Second sheet i.e Issue: It is basically for issueance of material to
production line having columns like : Doc. No. (issue slip no.), Date, Part
No. Description, Quantity Issued, Remarks.
The third sheet is Despatches, despatches is being imported from access
database, the date field is in "DD/MM/YYYY HH:MM:SS" format. (here the
evalute funtion doesn't work).
The fourth sheet is the summery sheet where the unique item list (standard
& constant) is there having columns: Part No., Description, Stock Quanity.
Now I am trying to generate the stocks on button click on certain conditions
say if user want to see the stock for any particular date then user have to
give the date via input box.
If user gives the date in input box then the code should search the value
for particular item satisfying the date contions like <=, in recpt, issue as
well as in despatches & put the
result value in summery sheet corresponding row. (All the entries in
database may have repeated, say one part may have recd twice / trice or so
on), then the variable should
store the sum of recpt, issue & despatches.
It is the simple arithmatic formula i.e: Stock as on User defined date =
Reciepts less than particular date)-(Issue less than user defined date +
despatches less than user defined date)
I have tried this by applying application.evaluate(sumproduct funtion). But
the data is huge caused slowed the report geretating process. Is there any
other solution for such report.
I have tried the following codes & getting the results but this is slowed
down the process.
Option Explicit
Dim myCell As Range
Sub Do_Summery()
Dim RequestedDate As Date
Dim ans, ans1, ans2, ans3 As Variant
RequestedDate = InputBox("Enter the report date in DD/MM/YYYY format ",
Format(Now, "DD/MM/YYYY"))
Worksheets("StockList").Range("E1") = "Stock as on " &
Format(RequestedDate, "dd/mm/yyyy")
Application.Calculation = xlCalculationManual
For Each myCell In Worksheets("StockList").Range("InputStockRng")
ans = Application.Evaluate("=sumproduct(('Recpt'!F2:F65500= """ _
& myCell.Value & """ )*('Recpt'!B2:B65500<=" &
CLng(RequestedDate) & ")*('Recpt'!G2:G65500))")
ans1 =
Application.Evaluate("=sumproduct(('Issue'!D265500= """ _
& myCell.Value & """ )*('Issue'!B2:B65500<=" &
CLng(RequestedDate) & ")*('Issue'!F2:F65500))")
'ans2 = Application.Evaluate("=sumproduct(('Desp'!E2:E65500= """ _
& myCell.Value & """ )*(int('Desp'!B2:B65500)=" &
CLng(RequestedDate) & "),('Desp'!J2:J65500))")
ans3 = ans1 + ans2
With myCell
.Offset(0, 3).Value = ans - ans3
End With
Next myCell
Set myCell = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub
Can we store variable like m = sum(if(('Recptuptolastfilledrow= """ _
& myCell.Value & """ )*(Recptuptolastfilledrow<=" &
CLng(RequestedDate) & ")*(Recptuptolastfilledrow))")
and so on. This may run the code faster & provide the desired report in a
fraction of seconds.
Further can we change the format of date field while importing the data into
excel from access. Such as with recordset(Field date)=format("DD/MM/YYYY") &
then copy the recodset to excel file.
Hope, I expressed it correctly. Any help in this regard will be highly
appreciated.