Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need a faster way to update values selected by advanced filter

I've got several worksheets with +30.000 rows, in one column (Q:Q) I need to
fill in values based on different criteria.

For that I use Advanced Filter(s) to determine which rows should be updated
with values from an Array, SLA(). Subsequently I loop through all rows in
activesheet.usedrange. If the row is not Hidden, then the column is updated.

here is part of the code:

Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("SelectSLA"), Unique:=False
Range("Q1").Select
For RData = 2 To ActiveSheet.UsedRange.Rows.Count
If Not Rows(RData).Hidden Then
Range("Q" & RData).FormulaR1C1 = SLA(Rsla, UBound(SLA, 2))
End If
Next

But this code is very slow. Does anyone know a faster way, to do this.
I need to repeat this section with 30-75 different criteria
(=Range("SelectSLA") is composed using af different loop)

/Tommy, DK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Need a faster way to update values selected by advanced filter

I don't know If this will help. But you can create a union of cells at the
beginning of the code and then use the union over aggain later in the code.
if you are using different coloumns then add an offset.


Sub test()

First = True
For RData = 2 To ActiveSheet.UsedRange.Rows.Count
If Not Rows(RData).Hidden Then
If First = True Then
Set NewRange = Range("Q" & RData)
First = False
Else
Set NewRange = Union(NewRange, Range("Q" & RData))

End If
End If
Next RData
NewRange.FormulaR1C1 = SLA(Rsla, UBound(SLA, 2))

End Sub


"TG4600, DK" wrote:

I've got several worksheets with +30.000 rows, in one column (Q:Q) I need to
fill in values based on different criteria.

For that I use Advanced Filter(s) to determine which rows should be updated
with values from an Array, SLA(). Subsequently I loop through all rows in
activesheet.usedrange. If the row is not Hidden, then the column is updated.

here is part of the code:

Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("SelectSLA"), Unique:=False
Range("Q1").Select
For RData = 2 To ActiveSheet.UsedRange.Rows.Count
If Not Rows(RData).Hidden Then
Range("Q" & RData).FormulaR1C1 = SLA(Rsla, UBound(SLA, 2))
End If
Next

But this code is very slow. Does anyone know a faster way, to do this.
I need to repeat this section with 30-75 different criteria
(=Range("SelectSLA") is composed using af different loop)

/Tommy, DK

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need a faster way to update values selected by advanced filter

Thank you, I did a test and the run-time was reduced from 44 sec to 38 sec.

In the mean time I have discovered that if I from a different workbook open
this workbook and the VBA Sub Auto_Open runs this code the run-time is
heavily increased.




"Joel" wrote:

I don't know If this will help. But you can create a union of cells at the
beginning of the code and then use the union over again later in the code.
if you are using different columns then add an offset.


Sub test()

First = True
For RData = 2 To ActiveSheet.UsedRange.Rows.Count
If Not Rows(RData).Hidden Then
If First = True Then
Set NewRange = Range("Q" & RData)
First = False
Else
Set NewRange = Union(NewRange, Range("Q" & RData))

End If
End If
Next RData
NewRange.FormulaR1C1 = SLA(Rsla, UBound(SLA, 2))

End Sub


"TG4600, DK" wrote:

I've got several worksheets with +30.000 rows, in one column (Q:Q) I need to
fill in values based on different criteria.

For that I use Advanced Filter(s) to determine which rows should be updated
with values from an Array, SLA(). Subsequently I loop through all rows in
activesheet.usedrange. If the row is not Hidden, then the column is updated.

here is part of the code:

Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("SelectSLA"), Unique:=False
Range("Q1").Select
For RData = 2 To ActiveSheet.UsedRange.Rows.Count
If Not Rows(RData).Hidden Then
Range("Q" & RData).FormulaR1C1 = SLA(Rsla, UBound(SLA, 2))
End If
Next

But this code is very slow. Does anyone know a faster way, to do this.
I need to repeat this section with 30-75 different criteria
(=Range("SelectSLA") is composed using af different loop)

/Tommy, DK

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
Using Advanced Filter: How do you MOVE the selected rows... ravif Excel Worksheet Functions 3 June 29th 09 10:25 PM
Updating values using advanced filter - VBA TG Excel Programming 0 December 19th 07 09:56 PM
Advanced Filter - Automatic Update michael90401 Excel Worksheet Functions 0 June 18th 07 06:00 PM
Advanced Filter for Values in Column M greater than Values in Colu SteveC Excel Discussion (Misc queries) 3 May 2nd 06 07:55 PM
Advanced Filter - Unique Values EstherJ Excel Programming 4 August 22nd 05 01:33 PM


All times are GMT +1. The time now is 12:32 AM.

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"