looking up cell value producing error

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
The red line of text has not produced an error before but now does and I'm not sure why. The cells of this line just have a word or set of numbers, a "password" of sorts. Any ideas what might pop the error?

Thanks.

Note: i've only pulled a section before this code is LONG. Happy to pull more if needed. Also- there are lots of little "development phase" notes....sorry.

Rich (BB code):
Private Sub Workbook_Open()


'On Error GoTo Helper
Dim sProcname As String
    Dim resp As String
'This will show the Userform 1 when starting and hide the excel sheet in the background
'Also checks to see if program has ever been run, and if not, loads program for the first time
Application.Visible = False
Dim s As String
Dim namer As String
Dim d As Variant
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




'ExpirationDate = (Sheets("Developer").Range("E37"))     'expiration date
'edate = Sheets("Developer").Range("E37")
namer = Sheets("Notes").Range("N4")                     'just a name






s = GetSetting("DemoTest", "Registration", "Username")
'Sheets("Developer").Unprotect Password:=Worksheets("Developer").Range("B15:E15").Value, UserInterfaceOnly:=True
If s = "" Then
        Sheets("Developer").Unprotect Password:=Worksheets("Developer").Range("B15:E15").Value, UserInterfaceOnly:=True
        Sheets("Developer").Range("B34:F34").ClearContents
        's = InputBox("Welcome to the " & namer & " Voyage Reporting System." & vbCrLf & "Please input the appropriate name to initialize the system for the first time." & vbCrLf & vbCrLf & "Note: this information can be modified later by clicking on the [Developer] button.", namer, "Bridge")
        'UserForm17.Show
        s = cInputBox()
        'MsgBox s
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Why do you have a range of cells for your password argument?
If you are pulling the password from the sheet, it is expecting it to be a single cell. It doesn't really make sense to have a password be a range of cells.
 
Upvote 0
I guess I had that because the cell was merged....so it was all the same cell really. Should I just delete the E15 part?

I've had it run before without issue.
 
Upvote 0
I guess I had that because the cell was merged....so it was all the same cell really. Should I just delete the E15 part?

I've had it run before without issue.
Yes, I would recommend that, and I would recommend getting rid of all your merged cells. They cause nothing but trouble, especially for VBA.
And if you are just doing horizontal merging, you can get the same visual effect without all the issues by using the "Center Across Selection" instead.
See: https://www.atlaspm.com/toms-tutori...er-across-selection-instead-of-merging-cells/
 
Upvote 0
@Joe4

So I unmerged (so now the password is only in B15) and then cut the :E15 out of my coding and it's popping the same error. Current password is "1234"

I've run this code before without issue but now it's causing an issue everytime....any other ideas?
 
Upvote 0
What is the exact text of the error?
 
Upvote 0
What is the exact text of the error?

So if I cut out the line of code (below) that was giving me the original problem, then it tells me that the sheet I am trying to change (trying to clear contents) is protected...so that's working. Putting that error'ing line of code back in, I get it highlighted and the error message is "1004 - Application defined or object defined error"

Code:
 Sheets("Developer").Unprotect Password:=Worksheets("Developer").Range("B15").Value, UserInterfaceOnly:=True
 
Upvote 0
Well it appears the problem might lie with "Userinterfaceonly:=True" because if I take that piece out of each line of code where I've used it (even with my password cells merged at B15:E15 or unmerged), it works as intended....ideas?
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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