Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Looking for better way than .formula = "countif....."

I managed to get this far with a tip, and it provides the output exactly as I
envisioned it. However, I am looking for a better way to achieve the same
result. What I don't like is that I am populating cells in order to do my
evaluation. It would be preferable if I can do the evaluations without
dumping a formula in a cell.

Thanks in advance for any help.

Bob

Sub InvTest()

' The purpose is to isolate duplicate entries and missing entries
' in summary form from a predetermined sequential range of
' numbers.

Dim firstTag, lastTag, Tag, recCnt, i As Integer
Dim dupPos, misPos As Integer

firstTag = Range("H1")
lastTag = Range("H2")
recCnt = lastTag - firstTag

Tag = firstTag
dupPos = 2
misPos = 2

Range("B1") = "Duplicates"
Range("C1") = "Missing"

For i = 2 To 2 + recCnt
Range("B" & i).Formula = "=CountIf(A:A, " & Tag & ")"

If Range("B" & i) 1 Then
Range("C" & dupPos) = Tag
dupPos = dupPos + 1
ElseIf Range("B" & i) = 0 Then
Range("D" & misPos) = Tag
misPos = misPos + 1
End If
Tag = Tag + 1
Next i
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Looking for better way than .formula = "countif....."

Give this modified For...Next statement a try:

For i = 2 To 2 + recCnt
myVar = WorksheetFunction.CountIf(Range("A:A"), Tag)

If myVar 1 Then
Range("C" & dupPos) = Tag
dupPos = dupPos + 1
ElseIf myVar = 0 Then
Range("D" & misPos) = Tag
misPos = misPos + 1
End If
Tag = Tag + 1
Next i


"Bob Zimski" wrote in message
...
I managed to get this far with a tip, and it provides the output exactly as
I
envisioned it. However, I am looking for a better way to achieve the same
result. What I don't like is that I am populating cells in order to do my
evaluation. It would be preferable if I can do the evaluations without
dumping a formula in a cell.

Thanks in advance for any help.

Bob

Sub InvTest()

' The purpose is to isolate duplicate entries and missing entries
' in summary form from a predetermined sequential range of
' numbers.

Dim firstTag, lastTag, Tag, recCnt, i As Integer
Dim dupPos, misPos As Integer

firstTag = Range("H1")
lastTag = Range("H2")
recCnt = lastTag - firstTag

Tag = firstTag
dupPos = 2
misPos = 2

Range("B1") = "Duplicates"
Range("C1") = "Missing"

For i = 2 To 2 + recCnt
Range("B" & i).Formula = "=CountIf(A:A, " & Tag & ")"

If Range("B" & i) 1 Then
Range("C" & dupPos) = Tag
dupPos = dupPos + 1
ElseIf Range("B" & i) = 0 Then
Range("D" & misPos) = Tag
misPos = misPos + 1
End If
Tag = Tag + 1
Next i
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Looking for better way than .formula = "countif....."

Hit the nail right on the head.

Thanks very much.

Bob

"JLGWhiz" wrote:

Give this modified For...Next statement a try:

For i = 2 To 2 + recCnt
myVar = WorksheetFunction.CountIf(Range("A:A"), Tag)

If myVar 1 Then
Range("C" & dupPos) = Tag
dupPos = dupPos + 1
ElseIf myVar = 0 Then
Range("D" & misPos) = Tag
misPos = misPos + 1
End If
Tag = Tag + 1
Next i


"Bob Zimski" wrote in message
...
I managed to get this far with a tip, and it provides the output exactly as
I
envisioned it. However, I am looking for a better way to achieve the same
result. What I don't like is that I am populating cells in order to do my
evaluation. It would be preferable if I can do the evaluations without
dumping a formula in a cell.

Thanks in advance for any help.

Bob

Sub InvTest()

' The purpose is to isolate duplicate entries and missing entries
' in summary form from a predetermined sequential range of
' numbers.

Dim firstTag, lastTag, Tag, recCnt, i As Integer
Dim dupPos, misPos As Integer

firstTag = Range("H1")
lastTag = Range("H2")
recCnt = lastTag - firstTag

Tag = firstTag
dupPos = 2
misPos = 2

Range("B1") = "Duplicates"
Range("C1") = "Missing"

For i = 2 To 2 + recCnt
Range("B" & i).Formula = "=CountIf(A:A, " & Tag & ")"

If Range("B" & i) 1 Then
Range("C" & dupPos) = Tag
dupPos = dupPos + 1
ElseIf Range("B" & i) = 0 Then
Range("D" & misPos) = Tag
misPos = misPos + 1
End If
Tag = Tag + 1
Next i
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write formula for countif (range,"<2" &"3") Vinod Tripathi Excel Discussion (Misc queries) 1 May 1st 09 07:27 AM
Difficulty "countif"-ing number of "L1" or "L2" on an autofiltered pmdoherty Excel Worksheet Functions 4 February 6th 09 11:23 AM
how does this formula work: =LOOKUP(2,1/((COUNTIF(D6:D41,""&D6:D41)=0)*(D6:D41<"")),D6:D41) Dave F[_2_] Excel Discussion (Misc queries) 7 February 1st 09 03:42 AM
can I nest COUNTIF functions(C5:C8,"apples") AND (D5:D8,"green") guycummins Excel Worksheet Functions 4 June 10th 08 09:23 PM
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... Maria J-son[_2_] Excel Programming 2 March 5th 06 12:20 PM


All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"