cell content check

grimshaw19

New Member
Joined
Jan 12, 2005
Messages
24
when i open a program its initiates a splashscreen on a userform with anput box asking for a password. I wanted to verify that the data entered into the cell is integer and hence the contentchk subroutine. However, when running, vba doesnt recognise that anything is typed into the input box and instead returns blankcell. Any ideas whats at fault?!?!

Private Sub UserForm_Click()
On Error GoTo ErrorHandler
inputpassword = Application.InputBox("Please Enter Your Password", "Security:Authorised Users Only", Type:=1)
ContentChk
Exit Sub

ErrorHandler:
MsgBox "The Password is Strictly Integer"
Resume Next
End Sub

Sub ContentChk()
If Application.IsText(ActiveCell) = True Then
MsgBox "The Password is Strictly Integer"
Else
End If
If ActiveCell = "" Then
MsgBox "Blank cell:The Password is Strictly Integer"
Else
End If
If ActiveCell.NumberFormat Then
CheckPassword
Else
If ActiveCell.HasFormula Then
MsgBox "Formula:The Password is Strictly Integer"
Else
End If
End If
If IsDate(ActiveCell.Value) = True Then
MsgBox "Date:The Password is Strictly Integer"
Else
End If
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I have tested this and it doesn't crash until it hits "CheckPassword" as you have not included this macro in your post.

Your issue may be elsewhere.
 
Upvote 0
Thanks for checking! - This is the password checker:

Sub CheckPassword()
On Error GoTo ErrorHandler
If inputpassword = Password& Then
MsgBox "Authorisation Cleared"
Application.Visible = True
Sheet1.Activate
UserForm1.Hide
Else
NumberofTries = NumberofTries + 1
If NumberofTries < 3 Then
MsgBox "Access Denied", vbExclamation + vbApplicationModal
'Sheet1.Activate 'To avoid return key problem
Else
MsgBox "Security Clearence Denied:Automatic Shutdown" & vbNewLine & "This disk will self distruct in T minus 10,9,8..."
UserForm1.Hide
ThisWorkbook.Close
End If
End If
Exit Sub

ErrorHandler:
MsgBox "The Password is Strictly Integer"
Resume Next

End Sub
 
Upvote 0
Try changing the userform to:
Private Sub UserForm_Click()
On Error GoTo ErrorHandler
inputpassword = Application.InputBox("Please Enter Your Password", "Security:Authorised Users Only", Type:=1)
[a1] = inputpassword
Range("a1").Select
ContentChk
Exit Sub

This assumes that A1 is a blank cell that can be used to check the password.
 
Upvote 0

Forum statistics

Threads
1,207,197
Messages
6,077,016
Members
446,250
Latest member
Dontcomehereoften

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