Excel/VBA problem
Expert: Chad Welch - 1/23/2007
QuestionGood Afternoon Expert
Can you take a look at this. No matter what I try, the name will not go into the cell. I get no errors. No VBA debugging and uResponse does = "password" when I do a break to check. It just doesn't seem to go to CASE IS.
Thanks
Todd
Private Sub CommandButton1_Click()
Dim uResponse As Variant
uResponse = InputBox("By entering your password you accept your payout" & vbCrLf & "as shown.")
Select Case uResponse
Case "password", "password1", uResponse
Case Is = "password"
'ActiveSheet.Unprotect "PassWordr"
[$F$39] = "Hector"
'ActiveSheet.Protect "PassWordr"
ActiveWorkbook.Save
Case Is = "password1"
'ActiveSheet.Unprotect "PassWordr"
ActiveSheet.Range("$F$39").Value = "Todd"
'ActiveSheet.Protect "PassWordr"
ActiveWorkbook.Save
Case Else
MsgBox "Invalid Password"
End Select
End Sub
AnswerTodd,
If you remove the following line the procedure should work for you:
Case "password", "password1", uResponse
Some programming languages require that type of a line defining the Cases, but Visual Basic doesn't need it. In fact it treats it as an actual case, so it checks if uResponse is equal to any of the three items listed. Since it is equal it performs any statements before the next case. There are no lines so it jumps directly to the End Select and nothing is done.
Chad Welch
Brainbench MVP for MS Excel
http://www.brainbench.com
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your
Excel question answered in this area then please ask an Excel question here