本文介绍了application.average有什么问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据以下条件删除工作表,但不起作用?出了什么问题?

I would like to delete sheets based on the following criteria, but doesn't work? What's wrong?

Private Sub Macro11(s As String)

Dim ws As Worksheet

Dim LastClose As Variant

Dim ThreeDay As Variant

Dim FiveDay As Variant

Dim TenDay As Variant

Dim TwentyDay As Variant

Dim FiftyDay As Variant

Dim OneHundredDay As Variant

Dim ThreeDayAvg As Variant

Dim FiveDayAvg As Variant

Dim TenDayAvg As Variant

Dim TwentyDayAvg As Variant

Dim FiftyDayAvg As Variant

Dim OneHundredDayAvg As Variant

Private Sub Macro11(s As String)
Dim ws As Worksheet
Dim LastClose As Variant
Dim ThreeDay As Variant
Dim FiveDay As Variant
Dim TenDay As Variant
Dim TwentyDay As Variant
Dim FiftyDay As Variant
Dim OneHundredDay As Variant
Dim ThreeDayAvg As Variant
Dim FiveDayAvg As Variant
Dim TenDayAvg As Variant
Dim TwentyDayAvg As Variant
Dim FiftyDayAvg As Variant
Dim OneHundredDayAvg As Variant

For Ws In Worksheets

ws.Activate

For Each ws In Worksheets
ws.Activate

Application.DisplayAlerts = False

Application.DisplayAlerts = False

LastClose = Cells(Rows。计数,"E")。结束(xlUp)。行

LastClose = Cells(Rows.Count, "E").End(xlUp).Row

ThreeDay =(范围(("E"& LastClose),范围("E"& LastClose) .Offset(-2,0)))

FiveDay =(范围(("E"& LastClose),范围("E"和"LastClose")。偏移(-4,0 ))))
TenDay =(范围(("E&q UOT; &安培; LastClose),Range("E"& LastClose)。Offset(-9,0)))$
TwentyDay =(Range(("E"& LastClose),Range(") E& LastClose)。偏移(-19,0))))
FiftyDay =(范围(("E"& LastClose),范围("E"& LastClose)。偏移(-49,0)))

OneHundredDay =(范围(("E"& LastClose),范围("E"和LastClose)。偏移(-49,0) ))

ThreeDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-2, 0)))
FiveDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-4, 0)))
TenDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-9, 0)))
TwentyDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-19, 0)))
FiftyDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-49, 0)))
OneHundredDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-49, 0)))

ThreeDayAvg = Application.Average(ThreeDay)

FiveDayAvg = Application.Average(FiveDay)

TenDayAvg = Application.Average (TenDay)

TwentyDayAvg = Application.Average(TwentyDay)

FiftyDayAvg = Application.Average(FiftyDay)

OneHundredDayAvg = Application.Average(FiftyDay) )

ThreeDayAvg = Application.Average(ThreeDay)
FiveDayAvg = Application.Average(FiveDay)
TenDayAvg = Application.Average(TenDay)
TwentyDayAvg = Application.Average(TwentyDay)
FiftyDayAvg = Application.Average(FiftyDay)
OneHundredDayAvg = Application.Average(FiftyDay)

如果ThreeDayAvg< FiveDayAvg和FiveDayAvg< TenDayAvg和TenDayAvg< TwentyDayAvg和TwentyDayAvg< FiftyDayAvg和FiftyDayAvg< OneHundredDayAvg然后是
ws.Delete

If ThreeDayAvg < FiveDayAvg And FiveDayAvg < TenDayAvg And TenDayAvg < TwentyDayAvg And TwentyDayAvg < FiftyDayAvg And FiftyDayAvg < OneHundredDayAvg Then
ws.Delete

结束如果

下一个ws

Application.DisplayAlerts = True

结束子

End If
Next ws
Application.DisplayAlerts = True
End Sub

谢谢。

推荐答案

FiftyDay与OneHundredDay相同,所以我认为OneHundredDayAvg看起来像这样:

FiftyDay is the same as OneHundredDay so, I think OneHundredDayAvg should look like this:

OneHundredDay =(范围(("E"& LastClose),范围("E"和"LastClose"。偏移( -99 ,0)))

OneHundredDay = (Range(("E" & LastClose), Range("E" & LastClose).Offset(-99, 0)))

 

FiftyDayAvg< OneHundredDayAvg

FiftyDayAvg < OneHundredDayAvg

总是相等,意味着条件永远不会被填满,OneHundredDayAvg应该是:

is always equal what means that condition is never fullfilled, again OneHundredDayAvg should be:

OneHundredDayAvg = Application.Average( OneHundredDay

OneHundredDayAvg = Application.Average(OneHundredDay)


这篇关于application.average有什么问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:50