Intro to Coding Help

Jim Wallace 1 Reputation point
2022-11-30T07:51:41.447+00:00

Hi,
I've been taking some night classes recently and we're working on Excel VBA in a business excel course.
I'm struggling to get my code to work like the teacher's.
Can anyone tell me what could be wrong with my code?
I'm trying to hide my financial statements behind a passcode, but when I put in the passcode it says it's wrong.
I'm in class right now and the teacher says to reach out to online forums for help with code.

Sub hideSheets()

Sheets("1. Income Statement").Visible = xlVeryHidden
Sheets("2. Balance Sheet").Visible = xlVeryHidden

End Sub

Sub showSheets()

Dim passcode As String
passcode = "JimWallace"
Dim answer As String
answer = InputBox("To view Financial Statements input employee passcode.","Passcode Required")
If answer = passcode Then
Sheets("1. Income Statement").Visible = True
Sheets("2. Balance Sheet").Visible = True
Sheets("1. Income Statement").Activate
Else
Dim Invalid As String
End If

End Sub

{count} votes