M
Mark1
My question is: In the first part of this code I set c, d, and e equal to
the S8, T8 and U8 ranges respectively. However, when I use them in my
sumproduct formula at the bottom of this code, they return P8 for c, Q8 for
d, and R8 for u. What's the deal? Thanks!!!
Sub MarkB()
Dim m As Long
Dim n As Long
Dim o As Long
Dim p As Long
Dim q As Long
Dim r As Long
Dim s As Long
Dim x As String
Dim w As String
Dim a As Range
Dim b As Range
Dim c As Range
Dim d As Range
Dim e As Range
Set a = ActiveSheet.Range("I8")
Set b = Cells.Find("TOTAL", , xlValues).Offset(-1, 8)
Set c = ActiveSheet.Range("S8")
Set d = ActiveSheet.Range("T8")
Set e = ActiveSheet.Range("U8")
For counter = 1 To (Worksheets.Count - 3)
Range("I7").Activate
Do Until ActiveCell.Offset(1, -7).Value = "TOTAL"
m = ActiveCell.Offset(1, 0).Value
n = ActiveCell.Offset(1, -3).Value
w = ActiveCell.Offset(1, -7).Value
x = ActiveCell.Offset(1, -6).Value
With ActiveCell.Offset(1, 0)
.Value = mark2(m, n)
.Activate
End With
With ActiveCell.Offset(0, 12)
.Value = mark2(m, n)
End With
With ActiveCell.Offset(0, 10)
.Value = w
End With
With ActiveCell.Offset(0, 11)
.Value = x
End With
Loop
Range("J7").Activate
Do Until ActiveCell.Offset(1, -8).Value = "TOTAL"
o = ActiveCell.Offset(1, 0).Value
p = ActiveCell.Offset(1, -3).Value
With ActiveCell.Offset(1, 0)
.Value = mark2(o, p)
.Activate
End With
With ActiveCell.Offset(0, 12)
.Value = mark2(o, p)
End With
Loop
Range(a, b).Formula = _
"=SUMPRODUCT(($B8=" & Range(c, b.Offset(0,
6)).Address(external:=True) & ")*($C8=" _
& Range(d, b.Offset(0, 7)).Address(external:=True) & ")*" & Range(e,
b.Offset(0, 8)).Address _
(ColumnAbsolute:=False, external:=True) & ")"
If Not ActiveSheet.Next Is Nothing Then
ActiveSheet.Next.Activate
End If
Next
End Sub
the S8, T8 and U8 ranges respectively. However, when I use them in my
sumproduct formula at the bottom of this code, they return P8 for c, Q8 for
d, and R8 for u. What's the deal? Thanks!!!
Sub MarkB()
Dim m As Long
Dim n As Long
Dim o As Long
Dim p As Long
Dim q As Long
Dim r As Long
Dim s As Long
Dim x As String
Dim w As String
Dim a As Range
Dim b As Range
Dim c As Range
Dim d As Range
Dim e As Range
Set a = ActiveSheet.Range("I8")
Set b = Cells.Find("TOTAL", , xlValues).Offset(-1, 8)
Set c = ActiveSheet.Range("S8")
Set d = ActiveSheet.Range("T8")
Set e = ActiveSheet.Range("U8")
For counter = 1 To (Worksheets.Count - 3)
Range("I7").Activate
Do Until ActiveCell.Offset(1, -7).Value = "TOTAL"
m = ActiveCell.Offset(1, 0).Value
n = ActiveCell.Offset(1, -3).Value
w = ActiveCell.Offset(1, -7).Value
x = ActiveCell.Offset(1, -6).Value
With ActiveCell.Offset(1, 0)
.Value = mark2(m, n)
.Activate
End With
With ActiveCell.Offset(0, 12)
.Value = mark2(m, n)
End With
With ActiveCell.Offset(0, 10)
.Value = w
End With
With ActiveCell.Offset(0, 11)
.Value = x
End With
Loop
Range("J7").Activate
Do Until ActiveCell.Offset(1, -8).Value = "TOTAL"
o = ActiveCell.Offset(1, 0).Value
p = ActiveCell.Offset(1, -3).Value
With ActiveCell.Offset(1, 0)
.Value = mark2(o, p)
.Activate
End With
With ActiveCell.Offset(0, 12)
.Value = mark2(o, p)
End With
Loop
Range(a, b).Formula = _
"=SUMPRODUCT(($B8=" & Range(c, b.Offset(0,
6)).Address(external:=True) & ")*($C8=" _
& Range(d, b.Offset(0, 7)).Address(external:=True) & ")*" & Range(e,
b.Offset(0, 8)).Address _
(ColumnAbsolute:=False, external:=True) & ")"
If Not ActiveSheet.Next Is Nothing Then
ActiveSheet.Next.Activate
End If
Next
End Sub