Emailing causing errors

moserz

New Member
Joined
Jul 12, 2006
Messages
20
I have emailed my excel worksheet to my boss and the code stops running as it should when he opens it. I open the same file on my computer and it works just fine. But when he gets it, error messages pop up as soon as he changes anything. Any ideas why? Is there a certain format I should be saving my worksheet as? I believe I am saving it as a "Microsoft Excel Worksheet."
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
The error that occurred was
"Method 'ColorIndex' of object 'Interior' failed

After looking into it a little bit, my boss is using Excel on a Mac, so for some reason it doesn't quite work on his computer. I've searched around on the internet and it seems like the biggest thing is that Windows uses ActiveX controls, but those don't work on a Mac. So my boss asked me to keep to the basics as to avoid using any ActiveX controls. The issue then is that I don't know what is an ActiveX control and what isn't. I felt like my code is pretty basic and didn't use anything fancy. I'll post the code so you can tell me what if anything I can rework so that it will work on a mac or if I basically just need to redo it. Thanks for any and all help.

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
  Dim VRange As Range
  Set VRange = Range("InputRange")
  If Intersect(Target, VRange) Is Nothing Then Exit Sub
      Select Case Target.Address
        Case "$D$5"
          answerCell = "E5"
          valuesAreEqual = CompareValues(Target.Value, "electron gun", False)
        Case "$D$7"
          answerCell = "E7"
          valuesAreEqual = CompareValues(Target.Value, "negative", False)
        Case "$D$9"
          answerCell = "E9"
          valuesAreEqual = CompareValues(Target.Value, "phosphor", False)
        Case "$D$11"
          answerCell = "E11"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$D$17"
          answerCell = "E17"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$D$22"
          answerCell = "E22"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$D$25"
          answerCell = "E25"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$D$30"
          answerCell = "E30"
          valuesAreEqual = CompareValues(Target.Value, 13, False)
        Case "$D$34"
          answerCell = "E34"
          valuesAreEqual = CompareValues(Target.Value, 44, False)
        Case "$B$38"
          answerCell = "B39"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$C$38"
          answerCell = "C39"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$D$38"
          answerCell = "D39"
          valuesAreEqual = CompareValues(Target.Value, "", True)
        Case "$D$45"
          answerCell = "E45"
          If Not IsNumeric(Evaluate("=" & Target)) Or Target = "" Then
            valuesAreEqual = -1
          Else
            Target.Value = Evaluate(Range("D45").Value)
            valuesAreEqual = CompareValues(Target.Value, 1.706 * 10 ^ 11, False)
          End If
        Case "$D$52"
          answerCell = "E52"
          valuesAreEqual = CompareValues(Target.Value, 3.07, False)
      End Select

    If (valuesAreEqual = 0) Then
      Range(answerCell).Value = "Will be graded later."
      Target.Interior.ColorIndex = xlNone
    ElseIf (valuesAreEqual = 1) Then
      Range(answerCell).Value = "Correct!"
      Target.Interior.ColorIndex = xlNone
    Else
      Range(answerCell).Value = "Try Again."
      Target.Interior.ColorIndex = 36
      Target.Activate
    End If
End Sub

Function CompareValues(UserValue, CorrectValue, WillBeGradedLater)
  UserValue = LCase(UserValue)
  If WillBeGradedLater Then
    CompareValues = 0
  ElseIf (InStr(UserValue, CorrectValue) <> 0) Then
    CompareValues = 1
  Else
    CompareValues = -1
  End If
End Function
 
Upvote 0

Forum statistics

Threads
1,213,559
Messages
6,114,302
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top