snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub save()
Dim pot As Range
Dim sent As Double
Set pot = Range("B2", Range("B" & Rows.Count).End(xlUp))
Set sent = Worksheets("Stock").Range("E2:E18")
sent = Application.WorksheetFunction.SumIfs(pot, pot.Offset(0, -1), sent.Offset(0, -2))
End Sub
Sub save()
Dim pot As Range
Dim sent As Range
With Sheets("stock")
For i = 2 To .Range("A" & .Rows.Count).End(xlUp) + 1
Set pot = Range("B2", Range("B" & Rows.Count).End(xlUp))
Set sent = Worksheets("Stock").Range("E" & i)
sent = Application.WorksheetFunction.SumIf(pot.Offset(0, -1), sent.Offset(0, -2), pot)
Next
End With
End Sub
Sub save()
Dim pot As Range
Dim sent As Range
With Sheets("stock")
For i = 5 To .Range("B" & .Rows.Count).End(xlUp) + 1
Set pot = Range("C5", Range("C" & Rows.Count).End(xlUp))
Set sent = Worksheets("Stock").Range("G" & i)
sent = Application.WorksheetFunction.SumIf(pot.Offset(0, -1), sent.Offset(0, -4), pot)
Next
End With
End Sub
Sub save()
Dim pot As Range
Dim sent As Range
With Sheets("stock")
For i = 5 To .Range("B" & .Rows.Count).End(xlUp) + 1
Set pot = Range("C5", Range("C" & Rows.Count).End(xlUp))
Set sent = Worksheets("Stock").Range("G" & i)
sent = Application.WorksheetFunction.SumIf(pot.Offset(0, -1), sent.Offset(0, -4), pot)
Next
End With
End Sub
Sub save()
Dim pot As Range
Dim sent As Range
With Sheets("stock")
For i = 4 To .Range("B1", .Range("B4").End(xlDown)).Rows.Count
Set pot = Range("C5", Range("C" & Rows.Count).End(xlUp))
Set sent = Worksheets("Stock").Range("G" & i)
sent = Application.WorksheetFunction.SumIf(pot.Offset(0, -1), sent.Offset(0, -4), pot)
Next
End With
End Sub