
我會盡量讓這個簡短而甜蜜。我正在制作檢查表,但遇到了角度尺寸問題。我的評估宏不適用于這些,我確定這是因為“°”字符。當遇到具有該字符的單元格時,有沒有辦法截斷或忽略“°”,以便回圈的其余部分可以按預期運行?
我希望避免這種情況,因為感覺就像向一堆倫勃朗展示我的手指畫,但這里有一大塊評估代碼。這包括“Shop Print Max”列中的非數字條目(在這些情況下,max 和 min 列通常合并為一個單元格)和僅“Shop Print Max”列中的數字條目。請溫柔點。直到一個多月前,我什至不知道如何訪問編輯器。
Sub Evaluate_Pre_Forge()
Dim R As Integer
Dim R2 As Integer
Dim Rng As Range
R = 12
R2 = 13
Do While (R < 70)
'(Text Entries in Column "N")
If (IsNumeric(Cells(R, 14))) = False Then
For Each Rng In Range(("T" & R), ("W" & R2))
If (Cells(R, 8) = "Y") = True Or (Cells(R, 8) = "y") = True Then
If Not IsEmpty(Rng) Then
If (IsNumeric(Rng)) = False And (Rng <> "Conforms") = True Then
Rng.Interior.Color = 16777215
ElseIf (IsNumeric(Rng)) = False And (Rng = "Conforms") = True Then
Rng.Interior.Color = 7862528
End If
End If
End If
Next Rng
ElseIf (IsNumeric(Cells(R, 14))) = True Then
'(Numeric Value in Column "N" Only)
If (Cells(R, 14).Value > 0) = True And (Cells(R, 17).Value <= 0) = True Then
For Each Rng In Range(("T" & R), ("W" & R2))
If (Cells(R, 8) = "Y") = True Or (Cells(R, 8) = "y") = True Then
If Not IsEmpty(Rng) Then
If (IsNumeric(Rng)) = True Then
'(Max Value Greater Than 100)
If Cells(R, 14).Value >= 100 Then
If (Rng.Value >= 100) Then
If Cells(R, 14).Value >= Rng.Value Then
Rng.Interior.Color = 7862528
End If
End If
If (Rng.Value < 100) And (Rng.Value >= 10) Then
Rng.Interior.Color = 7862528
End If
If (Rng.Value < 10) And (Rng.Value >= 0) Then
Rng.Interior.Color = 7862528
End If
End If
'(Max Value Between 10 and 100)
If Cells(R, 14).Value < 100 And Cells(R, 14).Value >= 10 Then
If (Rng.Value < 100) And (Rng.Value >= 10) Then
If Cells(R, 14).Value >= Rng.Value Then
Rng.Interior.Color = 7862528
End If
End If
If (Rng.Value < 10) And (Rng.Value >= 0) Then
Rng.Interior.Color = 7862528
End If
End If
'(Max Value Between 0 and 10)
If Cells(R, 14).Value < 10 Then
If (Rng.Value < 10) And (Rng.Value >= 0) Then
If Cells(R, 14).Value >= Rng.Value Then
Rng.Interior.Color = 7862528
End If
End If
End If
ElseIf (IsNumeric(Rng)) = False And Rng = "Conforms" Then
Rng.Interior.Color = 7862528
End If
End If
End If
Next Rng
End If
End If
R = R 2
R2 = R2 2
Loop
End Sub
uj5u.com熱心網友回復:
怎么樣Replace([YourReferenceHere], "°", "")?這將用空字串替換特殊字符。
uj5u.com熱心網友回復:
您可以使用if陳述句輕松檢查。請參閱以下示例:
cv = Sheet1.Cells(1, 1)
If Right(Trim(cv), 1) = "°" Then
cv = Left(Trim(cv), Len(cv) - 1)
End If
uj5u.com熱心網友回復:
您可以簡單地使用val功能。它將包含在字串中的數字作為適當型別的數值回傳。
關于 val 函式
示例 vba:
Dim MyValue
MyValue = Val("100.5°") ' Returns 100.5
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/323725.html
