Hello Excel Macro Experts!
I'm having an issue with this macro. It was originally written for a Windows machine but I've been forced to work on a Mac and because, from what I understand, Mac Excel doesn't have a scripting dictionary it's not working. I get a Runtime Error 429 when I try to run it, highlighting the CreateObject("Scripting.Dictionary").
Can anyone let me know how to make this script work in Excel Mac?
Thanks,
Steve
Sub ClearCells()
Const sGroupsSheetName As String = "Groups"
Const sStopWordsSheetName As String = "StopWords"
Dim objStopWords As Object
Dim rCur As Range
Dim sCurWord As String
Dim wsGroups As Worksheet
Dim wsStopwords As Worksheet
Set objStopWords = Nothing
Set objStopWords = CreateObject("Scripting.Dictionary")
With Sheets(sStopWordsSheetName)
For Each rCur In Intersect(.Columns("A"), .UsedRange)
sCurWord = LCase$(Trim$(CStr(rCur.Value)))
If sCurWord <> "" Then
On Error Resume Next
objStopWords.Add Key:=sCurWord, Item:=1
On Error GoTo 0
End If
Next rCur
End With
With Sheets(sGroupsSheetName)
For Each rCur In .UsedRange
sCurWord = LCase$(Trim$(CStr(rCur.Value)))
If sCurWord <> "" Then
If objStopWords.exists(sCurWord) Then rCur.ClearContents
End If
Next rCur
End With
objStopWords.RemoveAll
Set objStopWords = Nothing
End Sub
Bookmarks