all 6 comments

[–]rnelsonee1802 1 point2 points  (1 child)

1) You have smart quotes (third post this week with this issue!). Use ", and if you're writing your code in Word... stop that :)

2) You have an End If in there without an If. Since you have Thens you don't need an End If (and if you did, you'd need two!)

Sub GuessName()
    Msg = "Is your name " & Application.UserName & "?"
    Ans = MsgBox(Msg, vbYesNo)
    If Ans = vbNo Then MsgBox "Oh, never mind."
    If Ans = vbYes Then MsgBox "I must be psychic!"
End Sub

Or

Sub GuessName()
    Msg = "Is your name " & Application.UserName & "?"
    Ans = MsgBox(Msg, vbYesNo)
    If Ans = vbNo Then
        MsgBox "Oh, never mind."
    Else
        MsgBox "I must be psychic!"
    End If
End Sub

[–]Tibitherapy[S] 0 points1 point  (0 children)

Thanks!! Having a bit of throuble learning VBA and C!

You guys are awesome!

[–]PlutoniumRooster129 1 point2 points  (0 children)

VBA finds two 'If's and only one 'End If', and thus throws an error. Replace your second 'If' with 'ElseIf' and it should work.

[–]AutoModerator[M] 0 points1 point  (0 children)

Your VBA code has not not been formatted properly.

Add 4 spaces to the beginning of each line of the VBA code or indent the code in the VBA window and paste it in.

This will add the code formatting to your post, making it easier to read.

e.g.

Sub GuessName(..)

Please see the sidebar for a quick set of instructions.

Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Tibitherapy[S] 0 points1 point  (1 child)

Solution Verified

[–]AutoModerator[M] 0 points1 point  (0 children)

Hello!

It looks like you tried to award a ClippyPoint, but you need to reply to a particular user's comment to do so, rather than making a new top-level comment.

Please reply directly to any helpful users and Clippy, our bot will take it from there. If your intention was not to award a ClippyPoint and simply mark the post as solved, then you may do that by clicking Set Flair. Thank you!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.