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

%3CLINGO-SUB%20id%3D%22lingo-sub-111707%22%20slang%3D%22en-US%22%3EHow%20to%20sum%20with%20a%20macro%20if%20the%20transaction%20is%20made%20in%20some%20currency%20and%20between%20certain%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-111707%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20to%20everybody%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20ask%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20in%20a%20table%20all%20the%20record%20of%20the%20sales.%20I%20need%20to%20know%20the%20amount%20sold%20between%20certian%20dates%20and%20in%20an%20specific%20currency%2C%20I%20have%20a%20table%20in%20which%20in%20column%20E%20is%20the%20amount%20of%20the%20transaction%2C%20in%20column%20F%20the%20currency%20(USD%2C%20EUR%2C%20etc)%20and%20in%20column%20I%20the%20date%20of%20the%20transaction.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20this%20moment%2C%20I%20use%20a%20Macro%20to%20give%20me%20the%20amount%20of%20sells%20made%20in%20an%20specific%20currency.%20The%20problem%20is%20when%20I%20want%20it%20to%20just%20sum%20the%20transaction%20that%20were%20done%20between%20certain%20dates%20(for%20example%20beteen%20January%201st%20and%20January%2015).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20macro%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20SumaDato()%3CBR%20%2F%3EDim%20i%2C%20j%20As%20Integer%3CBR%20%2F%3EDim%20filas%20As%20Integer%3CBR%20%2F%3EDim%26nbsp%3BCurrency%20As%20String%3CBR%20%2F%3EDim%20Suma%20As%20Double%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ECurrency%26nbsp%3B%3D%20Range(%22curr%22)%3CBR%20%2F%3ESuma%20%3D%200%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20i%20%3D%203%20To%20Worksheets.Count%3CBR%20%2F%3Efilas%20%3D%20Worksheets(i).Cells(Rows.Count%2C%201).End(xlUp).Row%3CBR%20%2F%3EFor%20j%20%3D%202%20To%20filas%3CBR%20%2F%3EIf%20Worksheets(i).Cells(j%2C%206)%20%3D%26nbsp%3BCurrency%20Then%3CBR%20%2F%3ESuma%20%3D%20Suma%20%2B%20Worksheets(i).Cells(j%2C%205).Value%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3ENext%20j%3CBR%20%2F%3ENext%20i%3CBR%20%2F%3ERange(%22total%22).Value%20%3D%20Suma%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-111707%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20%26amp%3B%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENeed%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-113013%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20How%20to%20sum%20with%20a%20macro%20if%20the%20transaction%20is%20made%20in%20some%20currency%20and%20between%20certain%20date%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-113013%22%20slang%3D%22en-US%22%3E%3CP%3EI%20forgot%20to%20tell%20that%20there%20is%20the%20same%20table%2C%20but%20with%20different%20information%20for%20each%20of%20the%20stores.%20Each%20store%20is%20each%20page%20of%20the%20book.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-112518%22%20slang%3D%22en-US%22%3ERE%3A%20How%20to%20sum%20with%20a%20macro%20if%20the%20transaction%20is%20made%20in%20some%20currency%20and%20between%20certain%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-112518%22%20slang%3D%22en-US%22%3EHi%20Cesar%2C%20Why%20don't%20you%20use%20a%20PivotTable%20instead%20with%20Date%20Filters%3F%20Rgds%3C%2FLINGO-BODY%3E
New 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.