Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim A&, Ti#, Ts$
With Target
If (.Row >= 7 And .Row <= 17 And .Row Mod 3 = 1) And (.Column >= 7 And .Column <= 16) And .Count = 1 Then
A = .Value
If (A < 48 Or A > 50) And (A <> 0 Or .Value <> "") Then
.Interior.Color = RGB(255, 255, 0)
Ti = (50 - A) / 1000
Ts = Format(Ti, "0.000")
.Offset(1, 0) = IIf(Ti > 0, "+" & Ts, Ts)
.Offset(1, 0).Interior.Color = RGB(170, 240, 190)
Else
.Interior.ColorIndex = xlNone
.Offset(1, 0).Interior.ColorIndex = xlNone
.Offset(1, 0) = ""
End If
End If
End With
Application.EnableEvents = True
End Sub作者: Andy2483 時間: 2022-11-23 16:45
Option Explicit
Function GetRangeStep(Mi As Long, Mx As Long, xArea As Range)
'自訂義函數 GetRangeStep(最小值,最大值,計算的儲存格)
'[G8]儲存格輸入 =GetRangeStep(48,50,G7)
'[G8]儲存格複製公式到其他儲存格
Dim xR As Range, xV$, Ti#, Ts$
Application.Volatile
If (xArea.Value < Mi Or xArea.Value > Mx) And xArea.Value <> "" Then
Ti = (50 - xArea) / 1000
Ts = Format(Ti, "0.000")
xV = IIf(Ti > 0, "+" & Ts, Ts)
Else
xV = ""
End If
GetRangeStep = xV
End Function作者: 劉大胃 時間: 2022-11-23 18:36