Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reduce duplicates to 1 with a count of how many before
Hi Claus, Because some of the serial numbers just happen to start with "P" but NO serial number will state with "P-", I made that change in the code. That errors out this line with a subscript out of range. arrOut(j - 1, 1) = myArr(i, 1) I made some random changes of the -1 and the other 1's but nothing worked. myCt = WorksheetFunction.CountIf(.Range("A1:A" & LRow), "P-" & "*") For i = LBound(myArr) To UBound(myArr) ReDim Preserve arrOut(myCt - 1, 1) If Left(myArr(i, 1), 1) = "P-" Then arrOut(j, 0) = myArr(i, 1) j = j + 1 Else arrOut(j - 1, 1) = myArr(i, 1) End If Next Howard |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reduce duplicates to 1 with a count of how many before
TYPO... <NO serial number will state with "P-", NO serial number will START with "P-", H'wd |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reduce duplicates to 1 with a count of how many before
I seem to have fixed it with the change in this line
'If Left(myArr(i, 1), 1) = "P-" Then If Left(myArr(i, 1), 2) = "P-" Then I would still like your opinion, however. myArr = .Range("A1:A" & LRow) myCt = WorksheetFunction.CountIf(.Range("A1:A" & LRow), "P-" & "*") For i = LBound(myArr) To UBound(myArr) ReDim Preserve arrOut(myCt - 1, 1) 'If Left(myArr(i, 1), 1) = "P-" Then If Left(myArr(i, 1), 2) = "P-" Then arrOut(j, 0) = myArr(i, 1) j = j + 1 Else arrOut(j - 1, 1) = myArr(i, 1) End If Next Howard |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reduce duplicates to 1 with a count of how many before
Hi Howard,
Am Tue, 25 Feb 2014 18:50:41 -0800 (PST) schrieb L. Howard: If Left(myArr(i, 1), 2) = "P-" Then if you have serial numbers starting with "P" this is the best way to fix it. Regards Claus B. -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reduce duplicates to 1 with a count of how many before
Hi again,
Am Tue, 25 Feb 2014 18:50:41 -0800 (PST) schrieb L. Howard: If Left(myArr(i, 1), 2) = "P-" Then if the product ID ALWAYS has 6 digits and the serial number NEVER you could also work with LEN Regards Claus B. -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
count duplicates | Excel Programming | |||
Count Duplicates | Excel Discussion (Misc queries) | |||
Count Employee Work Time - Don't Count Duplicates | Excel Worksheet Functions | |||
Reduce columns and rows count? | Excel Worksheet Functions | |||
count a group of numbers but do not count duplicates | Excel Worksheet Functions |