Consulting

Results 1 to 5 of 5

Thread: sum data based on dates from sheet to another

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    sum data based on dates from sheet to another

    hello
    i try sum data based on cell value contains date so whan i write the date in g2 it supposes sum from the first date to what i write in g2 and copy theses data from a2:e to sheet2 this my code doesn't work also not give me error
    HTML Code:
     Dim l As LongDim LastRow As Long
    Dim oWkSht As Worksheet
    Dim FirstDate As Date
    Dim LastDate As Date
    'Dim tsales As Long  '<-- not used in this code
    
    Set oWkSht = Worksheets("sheet2")
    
    FirstDate = DateSerial(Year(Date), Month(Date), 1)
    LastDate = DateSerial(Year(Date), Month(Date) + 1, 0)
    
    LastRow = oWkSht.Range("A100000").End(xlUp).Row
    
    Sheets("sheet1").Range("g2").Value = Application.WorksheetFunction.SumIfs(oWkSht.Range("e2:e" & LastRow), oWkSht.Range("a2:a" & LastRow), ">=" & CLng(FirstDate), oWkSht.Range("a2:a" & LastRow), "<=" & CLng(LastDate))
    
    End sub
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •