B
bst
i'm working on an inventory tracking sheet that has a snapshot of data
for the current week and the week before. it tracks changes in inventory
assignment. i have already built an array that has each unique id for
the inventory that is being tracked. i then want to loop the array
applying an autofilter on the sheet with the criteria based on the array
data. the result of the autofilter (not counting the header) either 1
row (the item has been removed from inventory) or two rows (the data is
still in inventory, need to check if it has been reassigned).
my problem is that i can't seem to test for how many rows resulted in
the autofilter.
what i have so far:
for xCtr = 1 to totalSerials
ActiveSheet.UsedRange.Select
Selection.AutoFilter field:=2, Criteria1:=uniqueSerials(xCtr)
Set filteredRange = selection.SpecialCells(xlCellTypeVisible)
if filteredRange.rows.count = 1 then
filteredRange.cells(2,colException).value = "x"
'row 2 because the first row is the header
end if
if filteredRange.rows.count = 2 then
if filteredRange.cells(2,colName).value <> _
filteredRange.cells(3, colName).value then
filteredRange.cells(2, colException).value = "x"
filteredRange.cells(3, colException).value = "x"
end if
end if
selection.autofilter
next xCtr
then i'll sort the sheet based on the exception column
the first time the macro is ran it works fine, afterwards
filteredRange.rows.count returns 1 everytime. i get the same results
with filteredRange.specialcells(xlCellTypeVisible).count
i have tried assigning filteredRange different ways as well with the
same results.
do i even need filteredRange? if not how should i proceed? if so, how
can i get it to work as desired? i've read about 10 pages of google
searching autofilter in the newsgroup and can't seem to find what i
need. copying the rows to another sheet would make the macro run too
long and is not desired since i want to sort the results of the
conditionals above.
TIA
bst
for the current week and the week before. it tracks changes in inventory
assignment. i have already built an array that has each unique id for
the inventory that is being tracked. i then want to loop the array
applying an autofilter on the sheet with the criteria based on the array
data. the result of the autofilter (not counting the header) either 1
row (the item has been removed from inventory) or two rows (the data is
still in inventory, need to check if it has been reassigned).
my problem is that i can't seem to test for how many rows resulted in
the autofilter.
what i have so far:
for xCtr = 1 to totalSerials
ActiveSheet.UsedRange.Select
Selection.AutoFilter field:=2, Criteria1:=uniqueSerials(xCtr)
Set filteredRange = selection.SpecialCells(xlCellTypeVisible)
if filteredRange.rows.count = 1 then
filteredRange.cells(2,colException).value = "x"
'row 2 because the first row is the header
end if
if filteredRange.rows.count = 2 then
if filteredRange.cells(2,colName).value <> _
filteredRange.cells(3, colName).value then
filteredRange.cells(2, colException).value = "x"
filteredRange.cells(3, colException).value = "x"
end if
end if
selection.autofilter
next xCtr
then i'll sort the sheet based on the exception column
the first time the macro is ran it works fine, afterwards
filteredRange.rows.count returns 1 everytime. i get the same results
with filteredRange.specialcells(xlCellTypeVisible).count
i have tried assigning filteredRange different ways as well with the
same results.
do i even need filteredRange? if not how should i proceed? if so, how
can i get it to work as desired? i've read about 10 pages of google
searching autofilter in the newsgroup and can't seem to find what i
need. copying the rows to another sheet would make the macro run too
long and is not desired since i want to sort the results of the
conditionals above.
TIA
bst