+ Reply to Thread
Results 1 to 7 of 7

Reference Cells For Passwords in Code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-12-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    421

    Reference Cells For Passwords in Code

    Hello,

    I have set passwords for some codes to run and declared like this:

    Const formprotect = "pass"
    Const Clerkpw = "clerk"

    How can I reference sheet 'Search'! cell D14 for "pass" and cell D15 for "clerk" ?

    Thanks,
    Fred

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,769

    Re: Reference Cells For Passwords in Code

    Try:

    Dim formprotect As String: formprotect = Sheets("Search").Range("D14").Value
    Dim Clerkpw As String:  Clerkpw = Sheets("Search").Range("D15").Value
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    03-12-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    421

    Re: Reference Cells For Passwords in Code

    I think I figured it out:

    Const formprotect = Trim(Sheets("Search").Range("D14").Value)
    Const Clerkpw = Trim(Sheets("Search").Range("D15").Value)

  4. #4
    Forum Contributor
    Join Date
    03-12-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    421

    Re: Reference Cells For Passwords in Code

    Oh I didn't see your reply TMS which is better?

  5. #5
    Forum Contributor
    Join Date
    03-12-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    421

    Re: Reference Cells For Passwords in Code

    I tried both but get errors can you try it please? I have the attached without any changes to code.

  6. #6
    Forum Contributor
    Join Date
    03-12-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    421

    Re: Reference Cells For Passwords in Code

    Isn't this like having a password that will apply to all codes?

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,769

    Re: Reference Cells For Passwords in Code

    I see this, and many of your other threads are marked solved, although I'm not sure we reached a conclusion for this one.

    For closure, if only mine, here is the way I think it could/should be done.

    Declare the Global Variables at the start of ModPWSecurity standard module
    ' Public/Global Variables
    Dim formprotect As String
    Dim Clerkpw As String
    Dim NewAFRpw As String
    
    ' Original Constants; no longer required
    'Const formprotect = "pass"
    'Const Clerkpw = "clerk"
    'Const NewAFRpw = formprotect
    Then, in the Workbook module, change the Workbook_Open event handler:

    Private Sub Workbook_Open()
    
    formprotect = Sheets("Search").Range("D14").Value
    Clerkpw = Sheets("Search").Range("D15").Value
    NewAFRpw = formprotect
    
    'Stop    ' for testing purposes to check password values are loaded as expected.
    
    Call FormLock
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can I code the passwords needed for ODBC links to SQLServer
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2016, 10:03 AM
  2. [SOLVED] Putting passwords in VBA code
    By MissDB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-09-2016, 06:31 AM
  3. Excel vba code for multi user logins and passwords
    By Willow350 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-08-2016, 10:26 PM
  4. Run VBA code based on multiple passwords.
    By ShakJames in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2015, 11:32 AM
  5. Changing my code to loop through a list of cells (lots of reference cells)
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2014, 12:31 PM
  6. Storing passwords in cells
    By anandvh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2012, 11:58 AM
  7. Excel 2007 error with code for creating passwords
    By CMSS in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-04-2010, 11:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1