Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

2 conditions Countif with offset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
St@cy - 26 Jan 2007 05:01 GMT
I need to count the number of disconnects, "D"s, in for each employee in the
month of x.   Each employee info takes a total of five lines.  The row
indicating the month is two lines above the type, where the "D"s would be
located.  The formula will be on a different sheet than the data and copied
down the column. Please help me with the right functions and/or macro.

Example:
'QA Input'
            D                   E       F .....IV
8   Employee1
9         Month              1        1      3
10        WO#  
11        Type               D        D      S
.
.
13  Employee2
14       Month
15       WO#
16       Type
Gary Keramidas - 26 Jan 2007 05:23 GMT
this formula on sheet2 will count the number of D's in row 11 if row 9 has a 1
in it

=SUMPRODUCT(--(Sheet1!E9:IV9=1),--(Sheet1!E11:IV11="D"))
Signature


Gary

>I need to count the number of disconnects, "D"s, in for each employee in the
> month of x.   Each employee info takes a total of five lines.  The row
[quoted text clipped - 15 lines]
> 15       WO#
> 16       Type
St@cy - 26 Jan 2007 05:46 GMT
Oh, thank you!  This did calucate my first employee.  Now, I need to copy the
formula down the column  with OFFSET some how in the mix.
Rows 9 & 11, 14 & 16, 19 & 21, ....  See the pattern?

> this formula on sheet2 will count the number of D's in row 11 if row 9 has a 1
> in it
[quoted text clipped - 19 lines]
> > 15       WO#
> > 16       Type
Gary Keramidas - 26 Jan 2007 06:13 GMT
what row and column will contain these formulas on the 2nd page?

Signature

Gary

> Oh, thank you!  This did calucate my first employee.  Now, I need to copy the
> formula down the column  with OFFSET some how in the mix.
[quoted text clipped - 24 lines]
>> > 15       WO#
>> > 16       Type
St@cy - 26 Jan 2007 06:35 GMT
J3 for Employee 1
J4 for Employee 2
.
.
etc.

> what row and column will contain these formulas on the 2nd page?
>
[quoted text clipped - 26 lines]
> >> > 15       WO#
> >> > 16       Type
Gary Keramidas - 26 Jan 2007 07:22 GMT
here you are:

Option Explicit

Sub emp_formulas()
Dim ws As Worksheet, ws2 As Worksheet
Dim i As Long, z As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("sheet2")
lastrow = ws.Cells(Rows.Count, "E").End(xlUp).Row
z = 3

     For i = 9 To lastrow Step 5
           ws2.Range("J" & z).Formula = "=SUMPRODUCT(--(Sheet1!E" & i & ":IV" &
i & _
           "=1),--(Sheet1!E" & i + 2 & ":IV" & i + 2 & "=""D""))"
           z = z + 1
Next

End Sub

Signature

Gary

> J3 for Employee 1
> J4 for Employee 2
[quoted text clipped - 37 lines]
>> >> > 15       WO#
>> >> > 16       Type
Gary Keramidas - 26 Jan 2007 07:35 GMT
hopefully this one won't wrap

Sub emp_formulas()
Dim ws As Worksheet, ws2 As Worksheet
Dim i As Long, z As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("sheet2")
lastrow = ws.Cells(Rows.Count, "E").End(xlUp).Row
z = 3

For i = 9 To lastrow Step 5
 ws2.Range("J" & z).Formula = "=SUMPRODUCT(--(Sheet1!E" & i & ":IV" & i & _
 "=1),--(Sheet1!E" & i + 2 & ":IV" & i + 2 & "=""D""))"
 z = z + 1
Next

End Sub

Signature

Gary

> here you are:
>
[quoted text clipped - 59 lines]
>>> >> > 15       WO#
>>> >> > 16       Type
St@cy - 26 Jan 2007 15:09 GMT
I change the sheet names, but this appears to be a procedure. I think I need
a function.??  =DisconnectCount(MonthSelected)

Sub DisconnectCount(MonthSelected)
Dim ws As Worksheet, ws2 As Worksheet
Dim i As Long, z As Long
Dim lastrow As Long
Set ws = Worksheets("QA Input")
Set ws2 = Worksheets("Monthly Report")
lastrow = ws.Cells(Rows.Count, "E").End(xlUp).row
z = 3
For i = 9 To lastrow Step 5
 ws2.Range("J" & z).Formula = "=SUMPRODUCT(--('QA Input'!E" & i & ":IV" & i
& _
 "=MonthSelected),--('QA Input'!E" & i + 2 & ":IV" & i + 2 & "=""D""))"
 z = z + 1
Next
End Sub

> hopefully this one won't wrap
>
[quoted text clipped - 78 lines]
> >>> >> > 15       WO#
> >>> >> > 16       Type
Gary Keramidas - 26 Jan 2007 23:25 GMT
you can either repost here or better yet, post in the excel function newsgroup.
this is generally for programming solutions, though the function experts read
here, too.

Signature

Gary

>I change the sheet names, but this appears to be a procedure. I think I need
> a function.??  =DisconnectCount(MonthSelected)
[quoted text clipped - 103 lines]
>> >>> >> > 15       WO#
>> >>> >> > 16       Type
Gary Keramidas - 26 Jan 2007 06:23 GMT
maybe you can adapt something from this. change the sheet references and the
location for the formulas, i have them starting on sheet2 cell A1.

Option Explicit

Sub emp_formulas()
Dim ws As Worksheet, ws2 As Worksheet
Dim i As Long, z As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("sheet2")
lastrow = ws.Cells(Rows.Count, "E").End(xlUp).Row
z = 1

     For i = 9 To lastrow Step 5
           ws2.Range("A" & z).Formula = "=SUMPRODUCT(--(Sheet1!E" & i & ":IV" &
i & _
           "=1),--(Sheet1!E" & i + 2 & ":IV" & i + 2 & "=""D""))"
           z = z + 1
Next

End Sub

Signature

Gary

> Oh, thank you!  This did calucate my first employee.  Now, I need to copy the
> formula down the column  with OFFSET some how in the mix.
[quoted text clipped - 24 lines]
>> > 15       WO#
>> > 16       Type
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.