+ Reply to Thread
Results 1 to 6 of 6

Run workbook only on select pc's based on serial number

  1. #1
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Run workbook only on select pc's based on serial number

    Hi Everyone,

    I run the macro below which tests the hard drives serial number. If it doesn't match the workbook will close.
    This works great on a single PC but I want to be able to have it test multiple serial numbers so it will run on
    any PC where one of the multiple serial numbers match but not quite sure how to get there?

    Any help would be appreciated.

    Thank you.

    Please Login or Register  to view this content.

  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,371

    Re: Run workbook only on select pc's based on serial number

    Set a variable to the value of the serial number of the drive. Then loop through a list of permitted serial numbers. If one matches, set a Boolean variable to true. If, at the end of the loop, the Boolean variable is still false, close the application.
    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
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Run workbook only on select pc's based on serial number

    This should just work fine just make sure you add a ; at both sides of the number

    Private Sub Workbook_Open()
    If InStr(1, ";-1464624812;456753469449;ASD-45678996;", ";" & CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber & ";", vbTextCompare) = False Then MsgBox "closing app", vbCritical 'Application.Quit

    End Sub

    grtz
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  4. #4
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Re: Run workbook only on select pc's based on serial number

    Thank you Joske920!! Works great!

  5. #5
    Registered User
    Join Date
    03-20-2023
    Location
    perth australia
    MS-Off Ver
    365
    Posts
    1

    Re: Run workbook only on select pc's based on serial number

    Hi Guys,

    would this VB script work on Auto_run? I have an excel sheet that i want to input the users Hard drive serial no into the script so when excel workbook loads they cannot share the worksheet with other computers if it doesnt match, but when I load the VB script under "this workbook" it is still loading the excel sheet even when the HD serial no is incorrect
    Last edited by Pukenevar; 03-20-2023 at 11:15 PM.

  6. #6
    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,371

    Re: Run workbook only on select pc's based on serial number

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

    However, seeing as you are here, see: https://www.pcreview.co.uk/threads/a...k_open.953960/

    I don't think the trick of holding down the shift key works any more.

    Note: it is Auto_Open not Auto_Run

+ 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. [SOLVED] Generate Serial number based on date
    By Jamesdlm in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-23-2019, 08:33 AM
  2. [SOLVED] How to sum cells based on a serial number
    By jilaba in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2019, 01:12 PM
  3. [SOLVED] how to put serial number based on a cell value / name
    By jilaba in forum Excel General
    Replies: 3
    Last Post: 02-14-2019, 02:26 PM
  4. match the loans based off of the serial number
    By kvpoteat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-14-2019, 01:00 PM
  5. code to generate serial number based on number of records
    By winmaxservices1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2015, 03:21 AM
  6. MACRO to generate serial number in shared workbook
    By mouzie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-30-2014, 05:31 AM
  7. [SOLVED] Protect use of workbook with serial number
    By adam2308 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-14-2011, 07:09 PM

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