沒有測過
Try Try 看
Sub Main()
Range("A1").Select
Do While ActiveCell.Value <> ""
If hasDBCS(ActiveCell) Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
Selection.Interior.ColorIndex = xlNone
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Function hasDBCS(ByVal str As String) As Boolean
For i = 1 To Len(str)
If Unicode(Mid(str, i, 1)) >= 44032 Then
If Unicode(Mid(str, i, 1)) <= 55203 Then
hasDBCS = True
Exit Function
End If
End If
Next
hasDBCS = False
End Function
若改成是否可行
感謝測試
Function hasDBCS(ByVal str As String) As Boolean
For i = 1 To Len(str)
If Application.WorksheetFunction.Unicode(Mid(str, i, 1)) >= 44032 Then
If Application.WorksheetFunction.Unicode(Mid(str, i, 1)) <= 55203 Then
hasDBCS = True
Exit Function
End If
End If
Next
hasDBCS = False
End Function
海大OK了。
非常感謝你的幫忙:DD
B1:
=IF(SUM(--(UNICODE(MID($A1,ROW(INDIRECT("1:"&LEN($A1))),1))>=44032)*--(UNICODE(MID($A1,ROW(INDIRECT("1:"&LEN($A1))),1))<=55203)),1,0)
按CTRL+SHIFT+ENTER鍵完成輸入,並複製到公式向下到B2:B4001。
框選A1:B4001。
再點取「常用 > 條件式格式設定 > 新增規則」。
結果
Sub test()
For i = 1 To [a1048576].End(xlUp).Row
For j = 1 To Len(Cells(i, "a"))
If WorksheetFunction.Unicode(Mid(Cells(i, "a"), j, 1)) >= 44032 And WorksheetFunction.Unicode(Mid(Cells(i, "a"), j, 1)) <= 55203 Then
Cells(i, "a").Interior.ColorIndex = 6
exit for
Else
Cells(i, "a").Interior.ColorIndex = xlNone
End If
Next
Next
End Sub