Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default What is the better way to scan cells after autofiler

I have a spreadsheet containing over 10K-30K rows of data. I need to provide
some calculation at a set of user defined criteria at runtime of macros.
I currently use the following 2 structions to filter out a set of data
(rows) based on 2 user defined criteria: AccountID and ProjectName. I'll then
sum up values on different columns as shown below:

Selection.AutoFilter Field:=1, Criteria1:=AccountID
Selection.AutoFilter Field:=3, Criteria1:=ProjectName
range("A2").select
ACWP=0
Do While Not IsEmpty(ActiveCell)
ActiveCell.offset(1, 0).Select
If ActiveCell.RowHeight < 0 Then
acwp = acwp + ActiveCell.Offset(0,5).Value
endif
Loop

Other than using "If ActiveCell.RowHeight < 0 Then" statement to go one row
at a time (including this hidden rows as result of autofilter). which is
quite time consuming.

Questin: Is there a faster method that will allow me just to look at rows
show up as result of AutoFiler ?

Thanks in advance for any suggestion.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default What is the better way to scan cells after autofiler

Hi Wellie,

Try something like:

Sub Tester02()
Dim sh As Worksheet
Dim MyTotal As Double
Dim rng As Range

Set sh = ActiveSheet '<<========CHANGE
MyTotal = 0

With sh.Range("A1")
.AutoFilter Field:=1, Criteria1:=AccountID
.AutoFilter Field:=3, Criteria1:=ProjectName
End With

On Error Resume Next
Set rng = sh.AutoFilter.Range.Columns(1) _
.SpecialCells(xlVisible)
On Error GoTo 0

MyTotal = Application.Sum(rng)

MsgBox MyTotal '<<====== For testing purposes only - DELETE

End Sub


---
Regards,
Norman



"Wellie" wrote in message
...
I have a spreadsheet containing over 10K-30K rows of data. I need to
provide
some calculation at a set of user defined criteria at runtime of macros.
I currently use the following 2 structions to filter out a set of data
(rows) based on 2 user defined criteria: AccountID and ProjectName. I'll
then
sum up values on different columns as shown below:

Selection.AutoFilter Field:=1, Criteria1:=AccountID
Selection.AutoFilter Field:=3, Criteria1:=ProjectName
range("A2").select
ACWP=0
Do While Not IsEmpty(ActiveCell)
ActiveCell.offset(1, 0).Select
If ActiveCell.RowHeight < 0 Then
acwp = acwp + ActiveCell.Offset(0,5).Value
endif
Loop

Other than using "If ActiveCell.RowHeight < 0 Then" statement to go one
row
at a time (including this hidden rows as result of autofilter). which is
quite time consuming.

Questin: Is there a faster method that will allow me just to look at rows
show up as result of AutoFiler ?

Thanks in advance for any suggestion.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default What is the better way to scan cells after autofiler

try
Sub whatever()
For Each C In Selection.SpecialCells(xlVisible)
If C.RowHeight < 0 Then acwp = acwp + C.Offset(0, 5)
Next
MsgBox acwp
End Sub

OR leave out the rowheight to see if you get the same
Sub whatever()
For Each C In Selection.SpecialCells(xlVisible)
acwp = acwp + C.Offset(0, 5)
Next
MsgBox acwp
End Sub

--
Don Guillett
SalesAid Software

"Wellie" wrote in message
...
I have a spreadsheet containing over 10K-30K rows of data. I need to

provide
some calculation at a set of user defined criteria at runtime of macros.
I currently use the following 2 structions to filter out a set of data
(rows) based on 2 user defined criteria: AccountID and ProjectName. I'll

then
sum up values on different columns as shown below:

Selection.AutoFilter Field:=1, Criteria1:=AccountID
Selection.AutoFilter Field:=3, Criteria1:=ProjectName
range("A2").select
ACWP=0
Do While Not IsEmpty(ActiveCell)
ActiveCell.offset(1, 0).Select
If ActiveCell.RowHeight < 0 Then
acwp = acwp + ActiveCell.Offset(0,5).Value
endif
Loop

Other than using "If ActiveCell.RowHeight < 0 Then" statement to go one

row
at a time (including this hidden rows as result of autofilter). which is
quite time consuming.

Questin: Is there a faster method that will allow me just to look at rows
show up as result of AutoFiler ?

Thanks in advance for any suggestion.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default What is the better way to scan cells after autofiler

Hi Wellie,

Change:

MyTotal = Application.Sum(rng)


to

MyTotal = Application.Sum(rng.Offset(0, 5))


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Wellie,

Try something like:

Sub Tester02()
Dim sh As Worksheet
Dim MyTotal As Double
Dim rng As Range

Set sh = ActiveSheet '<<========CHANGE
MyTotal = 0

With sh.Range("A1")
.AutoFilter Field:=1, Criteria1:=AccountID
.AutoFilter Field:=3, Criteria1:=ProjectName
End With

On Error Resume Next
Set rng = sh.AutoFilter.Range.Columns(1) _
.SpecialCells(xlVisible)
On Error GoTo 0

MyTotal = Application.Sum(rng)

MsgBox MyTotal '<<====== For testing purposes only - DELETE

End Sub


---
Regards,
Norman



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default What is the better way to scan cells after autofiler

Thanks Don,

I tried your method, it moves to next cell on the same row instead of nex
visible row.

Can you plz tell me what in struction is required to move to next visible
row ?

Thanks again in advance.

"Don Guillett" wrote:

try
Sub whatever()
For Each C In Selection.SpecialCells(xlVisible)
If C.RowHeight < 0 Then acwp = acwp + C.Offset(0, 5)
Next
MsgBox acwp
End Sub

OR leave out the rowheight to see if you get the same
Sub whatever()
For Each C In Selection.SpecialCells(xlVisible)
acwp = acwp + C.Offset(0, 5)
Next
MsgBox acwp
End Sub

--
Don Guillett
SalesAid Software

"Wellie" wrote in message
...
I have a spreadsheet containing over 10K-30K rows of data. I need to

provide
some calculation at a set of user defined criteria at runtime of macros.
I currently use the following 2 structions to filter out a set of data
(rows) based on 2 user defined criteria: AccountID and ProjectName. I'll

then
sum up values on different columns as shown below:

Selection.AutoFilter Field:=1, Criteria1:=AccountID
Selection.AutoFilter Field:=3, Criteria1:=ProjectName
range("A2").select
ACWP=0
Do While Not IsEmpty(ActiveCell)
ActiveCell.offset(1, 0).Select
If ActiveCell.RowHeight < 0 Then
acwp = acwp + ActiveCell.Offset(0,5).Value
endif
Loop

Other than using "If ActiveCell.RowHeight < 0 Then" statement to go one

row
at a time (including this hidden rows as result of autofilter). which is
quite time consuming.

Questin: Is there a faster method that will allow me just to look at rows
show up as result of AutoFiler ?

Thanks in advance for any suggestion.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default What is the better way to scan cells after autofiler

I just re-tested and both versions worked fine. How did you modify?? Post
your code.

--
Don Guillett
SalesAid Software

"Wellie" wrote in message
...
Thanks Don,

I tried your method, it moves to next cell on the same row instead of nex
visible row.

Can you plz tell me what in struction is required to move to next visible
row ?

Thanks again in advance.

"Don Guillett" wrote:

try
Sub whatever()
For Each C In Selection.SpecialCells(xlVisible)
If C.RowHeight < 0 Then acwp = acwp + C.Offset(0, 5)
Next
MsgBox acwp
End Sub

OR leave out the rowheight to see if you get the same
Sub whatever()
For Each C In Selection.SpecialCells(xlVisible)
acwp = acwp + C.Offset(0, 5)
Next
MsgBox acwp
End Sub

--
Don Guillett
SalesAid Software

"Wellie" wrote in message
...
I have a spreadsheet containing over 10K-30K rows of data. I need to

provide
some calculation at a set of user defined criteria at runtime of

macros.
I currently use the following 2 structions to filter out a set of data
(rows) based on 2 user defined criteria: AccountID and ProjectName.

I'll
then
sum up values on different columns as shown below:

Selection.AutoFilter Field:=1, Criteria1:=AccountID
Selection.AutoFilter Field:=3, Criteria1:=ProjectName
range("A2").select
ACWP=0
Do While Not IsEmpty(ActiveCell)
ActiveCell.offset(1, 0).Select
If ActiveCell.RowHeight < 0 Then
acwp = acwp + ActiveCell.Offset(0,5).Value
endif
Loop

Other than using "If ActiveCell.RowHeight < 0 Then" statement to go

one
row
at a time (including this hidden rows as result of autofilter). which

is
quite time consuming.

Questin: Is there a faster method that will allow me just to look at

rows
show up as result of AutoFiler ?

Thanks in advance for any suggestion.






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
Autofiler issue PWS Excel Discussion (Misc queries) 0 April 17th 07 04:12 PM
Protect Autofiler Column mickey Excel Discussion (Misc queries) 5 February 8th 07 07:09 PM
Scan from a document to excel with separate cells Shannon Y Excel Discussion (Misc queries) 1 January 6th 07 05:04 PM
autofiler disabled yaronsh8 Excel Discussion (Misc queries) 4 June 12th 06 02:21 PM
Scan and copy cells from one spreadsheet to another. Mark Excel Discussion (Misc queries) 1 April 6th 05 06:45 PM


All times are GMT +1. The time now is 11:14 PM.

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

About Us

"It's about Microsoft Excel"