+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 refer to rows in separate worksheet, workbook

  1. #1
    Registered User
    Join Date
    07-29-2010
    Location
    Cleveland, Ohio, US
    MS-Off Ver
    Excel 2007
    Posts
    20

    Excel 2007 refer to rows in separate worksheet, workbook

    I am running an InputBox, and depending on what password the user enters, it executes certain macros. However, if the user does not enter anything or enters an invalid password, I want it to bring up an error message using a msgbox. I have the accepted passwords in a row on a separate worksheet. How can I reference that row with an "If ...Then" statement to determine whether the password entered is valid? Furthermore, if the cancel button is selected, how can I get the entire workbook to close?

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    Is there a reason why you want to keep the passwords in a separate workbook? You could hold them on a Very Hidden worksheet in the same workbook which would be simpler. I'm guessing as you're using Excel security isn't a major priority.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    07-29-2010
    Location
    Cleveland, Ohio, US
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    A veryhidden worksheet would work fine as well

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    I've attached a basic example.

    Dom
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-29-2010
    Location
    Cleveland, Ohio, US
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    I'm not quite sure I understand your 'set' statement. Is there any way you could clarify it so I can make it fit my data? I think it will solve my problem.

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    Please Login or Register  to view this content.

    What this is doing is searching the area from A1 down to the last populated cell in column A on the Passwords sheet using the Find method. If a match is found it will set the rngFindRange object to the range of the matched item. If not rngFindRange will remain empty (Nothing).

    Dom

  7. #7
    Registered User
    Join Date
    07-29-2010
    Location
    Cleveland, Ohio, US
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    I am getting a syntax error when I try to run the macro. What have I missed?

    Please Login or Register  to view this content.
    In addition, how can I get the inputbox to repeat when an invalid name is entered, or excel to close when cancel is clicked, instead of the macro closing?
    Last edited by CMSS; 08-03-2010 at 12:46 PM.

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    This is just a one line statement so the _ on the end would cause an error:

    Please Login or Register  to view this content.

    Dom

  9. #9
    Registered User
    Join Date
    07-29-2010
    Location
    Cleveland, Ohio, US
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Excel 2007 refer to rows in separate worksheet, workbook

    I caught that, but that wasn't the reason for the error. I get an error message reading 'Invalid or unqualified reference' that highlights .Cells in
    Please Login or Register  to view this content.
    Also, could you address the question I asked at the end of my last post? Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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