How to sum with a macro if the transaction is made in some currency and between certain dates

Copper Contributor

Hello to everybody,

 

I would like to ask for your help.

 

I have in a table all the record of the sales. I need to know the amount sold between certian dates and in an specific currency, I have a table in which in column E is the amount of the transaction, in column F the currency (USD, EUR, etc) and in column I the date of the transaction.

 

At this moment, I use a Macro to give me the amount of sells made in an specific currency. The problem is when I want it to just sum the transaction that were done between certain dates (for example beteen January 1st and January 15).

 

The macro is:

 

Sub SumaDato()
Dim i, j As Integer
Dim filas As Integer
Dim Currency As String
Dim Suma As Double


Currency = Range("curr")
Suma = 0

For i = 3 To Worksheets.Count
filas = Worksheets(i).Cells(Rows.Count, 1).End(xlUp).Row
For j = 2 To filas
If Worksheets(i).Cells(j, 6) = Currency Then
Suma = Suma + Worksheets(i).Cells(j, 5).Value
End If
Next j
Next i
Range("total").Value = Suma

End Sub

 

Thank You

2 Replies
Hi Cesar, Why don't you use a PivotTable instead with Date Filters? Rgds

I forgot to tell that there is the same table, but with different information for each of the stores. Each store is each page of the book.