我遇到了一些问题,我的宏与OSX兼容,它可以在windows上运行。
我有以下问题:
编译错误:在MAC上的Office 2016上运行宏时无法找到项目或库错误
代码/功能用于将特定范围更改为大写/正确大小写。调试器突出显示"UCase(Cell)"
和"Cell"
Sub ChkSheet()
'=========================================================================
' Format the cell boarders when the info needs to be corrected or updated
'=========================================================================
Dim historyWks As Worksheet
Set historyWks = Worksheets("Namelist")
Dim lRow As Long
Dim emailRng As Range
Dim Cell As Range
With historyWks
' Flags cells where the Email fieldcontains invalid characters
lRow = Range("G" & Rows.Count).End(xlUp).Row
Set emailRng = Range("Q2:Q" & lRow)
For Each Cell In emailRng
If Cell.Value = "," _
Or Cell.Value = " " _
Or Cell.Value = "wd" _
Or Cell.Value = "" _
Or Cell.Find("@") Is Nothing Then
Cell.Interior.Color = vbRed
Else:
Cell.Interior.ColorIndex = 0
End If
Next
'Change the text case
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
For Each Cell In Range("NListUpper")
Select Case True
Case Application.IsText(Cell) = True
Cell = UCase(Cell)
End Select
Next Cell
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
'Change the case to proper
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
For Each Cell In Range("NListProp")
Select Case True
Case Application.IsText(Cell) = True
Cell = StrConv(Cell, vbProperCase)
End Select
Next Cell
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End With
End Sub
我注意到OSX上的Excel 2016上缺少一些库,我知道MS已经从Excel中删除了许多用于OSX的库。
对此的任何建议都会很棒。
答案 0 :(得分:1)
您可以尝试避免使用Range
对象的默认属性 - 它们可能在Windows和OSX之间有所不同:
所以,而不是:
Select Case True
Case Application.IsText(Cell) = True
Cell = UCase(Cell)
End Select
你能尝试一下:
If Application.IsText(Cell.Value) Then
Cell.Value = UCase(Cell.Value)
End If