probably easier for me to code it for you. what i did was write code to create a
formula. there's a shorter way, but creating the formula in the cell will show
you how the result was accomplished.
i use sheet1 and sheet2 in my code and you would need to change the names if
yours are named differently.
not sure what you know about vba, but open the vb editor and under project
explorer you should see all of the sheets listed, double click on sheet2 and
paste the following code.
then go to sheet2 and change the values in A1: c1 and see if you get the correct
result.
i also pasted the code with line numbers in case any of it wrapped incorrectly
so you can try to place the line breaks..
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim lastrow As Long
Dim rngfound As Range
Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
If Not Intersect(Target, ws2.Range("C1")) Is Nothing Then
With ws.Range("A1:A" & lastrow)
Set rngfound = .Find(ws2.Range("C1"), lookat:=xlWhole)
If Not rngfound Is Nothing Then
ws2.Range("D1").Formula = "=SUMIF(Sheet1!B1:Z1," & """>=""" & _
"&A1" & ",Sheet1!B" & rngfound.Row & ":Z" & rngfound.Row & _
")-SUMIF(Sheet1!B1:Z1," & """>""" & "&B1" & ",Sheet1!B" & _
rngfound.Row & ":Z" & rngfound.Row & ")"
End If
End With
End If
End Sub
=============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim lastrow As Long
Dim rngfound As Range
10 Set ws = Worksheets("Sheet1")
20 Set ws2 = Worksheets("Sheet2")
30 lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
40 If Not Intersect(Target, ws2.Range("C1")) Is Nothing Then
50 With ws.Range("A1:A" & lastrow)
60 Set rngfound = .Find(ws2.Range("C1"), lookat:=xlWhole)
70 If Not rngfound Is Nothing Then
80 ws2.Range("D1").Formula = "=SUMIF(Sheet1!B1:Z1," & """>=""" &
_
"&A1" & ",Sheet1!B" & rngfound.Row & ":Z" & rngfound.Row
& _
")-SUMIF(Sheet1!B1:Z1," & """>""" & "&B1" & ",Sheet1!B" &
_
rngfound.Row & ":Z" & rngfound.Row & ")"
90 End If
100 End With
110 End If
End Sub