Hi, I have a set of data that need to be summarize. I need to calculate for total cost for each person based on criteria that will be chosen from two comboboxes in certain period (example:21Nov2018-20Dec2018). Anyone know how to do this? Please guide me.
Private Sub CommandButton1_Click()
Dim dbsheet, summarysheet As Worksheet
Dim erow As Long
Set dbsheet = ThisWorkbook.Sheets("DB")
Set summarysheet = ThisWorkbook.Sheets("summary")
lr = dbsheet.Cells(Rows.Count, 1).End(xlUp).Row
stdate = [c8]
enddate = [c9]
Range("J12").Value = Application.WorksheetFunction.DSum(Range("DB", E, ComboBox1, ComboBox3))
End If
summarysheet.Range("E2").Value = ComboBox1
summarysheet.Range("F2").Value = ComboBox3
summarysheet.Range("G2").Value = counter
End Sub
Private Sub UserForm_Initialize()
Dim d As Object, va, i As Long
Set d = CreateObject("scripting.dictionary")
d.CompareMode = vbTextCompare
va = Sheets("DB").Range("F2", Sheets("DB").Cells(Rows.Count, "F").End(xlUp))
For i = 1 To UBound(va, 1)
d(va(i, 1)) = ""
Next
ComboBox1.List = d.keys
d.RemoveAll
va = Sheets("DB").Range("K2", Sheets("DB").Cells(Rows.Count, "K").End(xlUp))
For i = 1 To UBound(va, 1)
d(va(i, 1)) = ""
Next
ComboBox3.List = d.keys
End Sub
Hi,
Can you please supply a workbook with sample data.
Thx
Phil
Here the file.
Hi Fatyn
From your example, you only need 2 values from the combo box i.e. Name and Job Allocation.
The formula for the summary calculation can be placed directly into the worksheet without using the macro.
See if this helps.
Sunny
Thank you Sunny. it helps a lot
You are welcome