PC Review


Reply
Thread Tools Rate Thread

Code ignoring filtered (visible) tasks.

 
 
=?Utf-8?B?RmluaXVzIEVldGNo?=
Guest
Posts: n/a
 
      16th Dec 2006
mycat is a string in my I column or column 9 (defined as MyCategoryCol)

Export_Info(mycat as string)
{
....misc variables.


' Apply my filter.
Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=mycat, Operator:=xlAnd

' Count the number of filtered tasks.
column_counter = Application.WorksheetFunction.Subtotal(3, Range("I:I"))


For i = 1 To column_counter



' The QUESTION
buff = Selection.Cells(i, MyQuestionCol)
ConBuff = ""
For j = 1 To Len(buff)
If InfFont(Asc(Mid(buff, j, 1))) = 255 Then
MsgBox "Unrecognised characters in Question at line " & i &
", character # " & j & " (" & Chr(InfFont(Asc(Mid(buff, j, 1)))) & "), table
entry " & Asc(Mid(buff, j, 1))
ConBuff = ConBuff + "?"
Else
ConBuff = ConBuff + Chr(InfFont(Asc(Mid(buff, j, 1))))
End If
Next j
Print #hfile, ConBuff

next i

.... many more sections of data, but they are all basically the same as this.

}


THE PROBLEM:
When I go through this loop, i always get the cells from the top, even ones
that should be filtered. I don't know why this happens. When I filter by
"Kids" for example, the 217 rows that have info about the "kids" even though
the actual row is at like 21,000 - I start getting entries from row 1, which
is usually a different column like "History"
 
Reply With Quote
 
 
 
 
Mike Fogleman
Guest
Posts: n/a
 
      17th Dec 2006
I am not sure you want to use column_counter on your filtered list because
your loop is going from row to row. If column_counter =100 then your loop
will evaluate rows(1:100). Your last filtered item may be on row 1900! It
may be best to loop the entire list and check each row's Hidden property.

For i = 1 to LastRow
If Rows(i).Hidden = False Then
'Do your code
Else
End If
Next i

Mike F
"Finius Eetch" <(E-Mail Removed)> wrote in message
news:80617A12-E1B3-4A44-BFF4-(E-Mail Removed)...
> mycat is a string in my I column or column 9 (defined as MyCategoryCol)
>
> Export_Info(mycat as string)
> {
> ...misc variables.
>
>
> ' Apply my filter.
> Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=mycat,
> Operator:=xlAnd
>
> ' Count the number of filtered tasks.
> column_counter = Application.WorksheetFunction.Subtotal(3, Range("I:I"))
>
>
> For i = 1 To column_counter
>
>
>
> ' The QUESTION
> buff = Selection.Cells(i, MyQuestionCol)
> ConBuff = ""
> For j = 1 To Len(buff)
> If InfFont(Asc(Mid(buff, j, 1))) = 255 Then
> MsgBox "Unrecognised characters in Question at line " & i &
> ", character # " & j & " (" & Chr(InfFont(Asc(Mid(buff, j, 1)))) & "),
> table
> entry " & Asc(Mid(buff, j, 1))
> ConBuff = ConBuff + "?"
> Else
> ConBuff = ConBuff + Chr(InfFont(Asc(Mid(buff, j, 1))))
> End If
> Next j
> Print #hfile, ConBuff
>
> next i
>
> ... many more sections of data, but they are all basically the same as
> this.
>
> }
>
>
> THE PROBLEM:
> When I go through this loop, i always get the cells from the top, even
> ones
> that should be filtered. I don't know why this happens. When I filter by
> "Kids" for example, the 217 rows that have info about the "kids" even
> though
> the actual row is at like 21,000 - I start getting entries from row 1,
> which
> is usually a different column like "History"



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to Fill Down in a filtered list only to visible cells. Training Goddess Microsoft Excel Programming 1 10th Feb 2009 10:35 AM
VBA code to Fill Down in a filtered list only to visible cells. Training Goddess Microsoft Excel Programming 1 10th Feb 2009 08:27 AM
VBA code to Fill Down in a filtered list only to visible cells. Training Goddess Microsoft Excel Programming 0 10th Feb 2009 12:18 AM
VBA code to Fill Down in a filtered list only to visible cells. Training Goddess Microsoft Excel Programming 0 10th Feb 2009 12:18 AM
By VBA , how to select the first visible cell (of first Visible row ) in filtered wor Amolin Microsoft Excel Misc 4 30th Jul 2004 12:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:04 PM.