Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default WTF?? Stange happings with a VB code

Ok, I'm using the below VB code and to my surprise, none of my formulas work.
Can any see why this is happing? When I remove the code, formulas work.
Strange.

Does it have to do with "With Application"?

Dim DeleteValue As String
Dim rng As Range
Dim calcmode As Long

With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
DeleteValue = "Closed"
With ActiveSheet
.AutoFilterMode = False
.Range("AE1:AE" & .Rows.Count).AutoFilter Field:=1,
Criteria1:=DeleteValue

With .AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
.AutoFilterMode = False
End With

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default WTF?? Stange happings with a VB code

You must set calculation back

See the complete code here
http://www.rondebruin.nl/delete.htm#AutoFilter


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"pgarcia" wrote in message ...
Ok, I'm using the below VB code and to my surprise, none of my formulas work.
Can any see why this is happing? When I remove the code, formulas work.
Strange.

Does it have to do with "With Application"?

Dim DeleteValue As String
Dim rng As Range
Dim calcmode As Long

With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
DeleteValue = "Closed"
With ActiveSheet
.AutoFilterMode = False
.Range("AE1:AE" & .Rows.Count).AutoFilter Field:=1,
Criteria1:=DeleteValue

With .AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
.AutoFilterMode = False
End With

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default WTF?? Stange happings with a VB code

Ah, and that's what I get for not taking a class. When I added the following
it work fine. Thanks Ron.

With Application
.ScreenUpdating = True
.Calculation = calcmode
End With

"Ron de Bruin" wrote:

You must set calculation back

See the complete code here
http://www.rondebruin.nl/delete.htm#AutoFilter


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"pgarcia" wrote in message ...
Ok, I'm using the below VB code and to my surprise, none of my formulas work.
Can any see why this is happing? When I remove the code, formulas work.
Strange.

Does it have to do with "With Application"?

Dim DeleteValue As String
Dim rng As Range
Dim calcmode As Long

With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
DeleteValue = "Closed"
With ActiveSheet
.AutoFilterMode = False
.Range("AE1:AE" & .Rows.Count).AutoFilter Field:=1,
Criteria1:=DeleteValue

With .AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
.AutoFilterMode = False
End With




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default WTF?? Stange happings with a VB code

Probably best to use

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.Calculation = calcmode
End With

so as to ensure the sheet gets recalculated in case it was originally manual


--
__________________________________
HTH

Bob

"pgarcia" wrote in message
...
Ah, and that's what I get for not taking a class. When I added the
following
it work fine. Thanks Ron.

With Application
.ScreenUpdating = True
.Calculation = calcmode
End With

"Ron de Bruin" wrote:

You must set calculation back

See the complete code here
http://www.rondebruin.nl/delete.htm#AutoFilter


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"pgarcia" wrote in message
...
Ok, I'm using the below VB code and to my surprise, none of my formulas
work.
Can any see why this is happing? When I remove the code, formulas work.
Strange.

Does it have to do with "With Application"?

Dim DeleteValue As String
Dim rng As Range
Dim calcmode As Long

With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
DeleteValue = "Closed"
With ActiveSheet
.AutoFilterMode = False
.Range("AE1:AE" & .Rows.Count).AutoFilter Field:=1,
Criteria1:=DeleteValue

With .AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
.AutoFilterMode = False
End With




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default WTF?? Stange happings with a VB code

Or just do the calculation:

With Application
.ScreenUpdating = True
.Calculate
.Calculation = calcmode
End With

Bob Phillips wrote:

Probably best to use

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.Calculation = calcmode
End With

so as to ensure the sheet gets recalculated in case it was originally manual

--
__________________________________
HTH

Bob

"pgarcia" wrote in message
...
Ah, and that's what I get for not taking a class. When I added the
following
it work fine. Thanks Ron.

With Application
.ScreenUpdating = True
.Calculation = calcmode
End With

"Ron de Bruin" wrote:

You must set calculation back

See the complete code here
http://www.rondebruin.nl/delete.htm#AutoFilter


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"pgarcia" wrote in message
...
Ok, I'm using the below VB code and to my surprise, none of my formulas
work.
Can any see why this is happing? When I remove the code, formulas work.
Strange.

Does it have to do with "With Application"?

Dim DeleteValue As String
Dim rng As Range
Dim calcmode As Long

With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
DeleteValue = "Closed"
With ActiveSheet
.AutoFilterMode = False
.Range("AE1:AE" & .Rows.Count).AutoFilter Field:=1,
Criteria1:=DeleteValue

With .AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
.AutoFilterMode = False
End With



--

Dave Peterson
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Stange numbers pgarcia Excel Discussion (Misc queries) 2 August 15th 08 06:25 PM
PivotTable Show Properties in Report - stange behaviour Gary Trend Excel Programming 0 January 18th 08 09:45 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 01:43 PM.

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"