dimming a cell

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
good morning,

I have some code that I've written/compiled for making a "registration key" of sorts for a workbook. Only issue, if the "password, as defined in cell B39, is a series of numbers, the coding works perfectly. if the password is a word or letters, it doesn't. I'm guessing I've got everything dimmed wrong.

Someone help please. thanks!

Code:
Dim s As StringDim namer As String
Dim d As String
Dim ExpirationDate As Date
Dim pass1 As String
Dim pass2 As String




With Sheets("Developer")
    s = .Range("B34")                   'username
    'pass1 = .Range("B15:E15").Value     'sheet unprotect
    'pass2 = .Range("B39").Value         'date password
    ExpirationDate = .Range("E37")      'expiration date
    d = .Range("B39").Value             'registration key
    initialdate = .Range("C36")         'initializing date
End With


TryAgain:
        d = Application.InputBox("Your workbook date has expired. Please enter the registration key to renew your license.", namer)
        If d = False Then Exit Sub
        If d = CStr(Worksheets("Developer").Range("B39").Value) Then
            Sheets("Developer").Range("C36") = Date
            MsgBox "Welcome Back " & s, vbOKOnly, namer
        Else
            MsgBox "Password Incorrect, Please try again.", vbCritical, namer
            GoTo TryAgain
        End If
    End If
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
If input box is cancelled then Application.Input box returns False (a boolean value)
So d must be able to handle boolean and strings and therefore must be type Variant

Code:
Dim d As Variant

and replace
Code:
If d = False Then Exit Sub
with
Code:
If d = "" Or d = False Then Exit Sub
 
Last edited:
Upvote 0
Use InputBox instead of Application.InputBox and change this,
Code:
If d = False Then Exit Sub
to this.
Code:
If d = "" Then Exit Sub
 
Upvote 0
out of curiosity, what's the difference between this and the line of code from @Yongle?

InputBox
ALWAYS returns a string (click on Cancel or X return a string)
Application.InputBox returns either a string or a boolean (Cancel or X)
 
Last edited:
Upvote 0

InputBox
ALWAYS returns a string (click on Cancel or X return a string)
Application.InputBox returns either a string or a boolean (Cancel or X)


So wouldn't I want application.inputbox (so the user either puts in a blank or wrong password or cancels and it's done)?
 
Upvote 0
You are checking for a string, why bring boolean values into it?
 
Upvote 0
I guess maybe I don't understand boolean values well enough. I understood them to be a true/false comparison.
I understand a string as just what's entered in the cell, regardless of number or text.
 
Upvote 0

Forum statistics

Threads
1,223,250
Messages
6,171,036
Members
452,374
Latest member
keccles

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