+ Reply to Thread
Results 1 to 6 of 6

Slight alteration/addition to my VBA code needed.

  1. #1
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Slight alteration/addition to my VBA code needed.

    Hi,

    I'm new to this and I've managed to copy a few different codes from this forum to suit my needs. Unfortunately I have one issue I just can't to find or sort out.

    In my code, if the operator inputs the wrong password a message box appears saying "Incorrect Password" and when the operator selects OK, the code asks to save the file.

    I would like the message box to have a retry option, and when retry is selected, the code starts again and doesn't ask to save the file.

    I hope this all makes sense.

    Any help will be much appreciated.

    Thanks

    Dan

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Slight alteration/addition to my VBA code needed.

    Hi @ danbates

    You can try adding this line:
    Please Login or Register  to view this content.
    And changing this:

    Please Login or Register  to view this content.
    Perhaps you need to Dim the variable Answer as integer
    Barriers are there for those who don't want to dream

  3. #3
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: Slight alteration/addition to my VBA code needed.

    Hi Vichopalacios,

    Thank you for replying but unfortunately I cant seem to get it to work. I've edited my code but it highlights the first line of you code "For Each cell In"

    Any ideas?

    I appreciate it could be me copying your code in the wrong place in my code, so I was wondering if you would edit my code above to how you think it should work and we can go from there?

    Thanks again for your help.

    Kind Regards
    Dan

  4. #4
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Slight alteration/addition to my VBA code needed.

    Perhaps I didn't myself clear.

    The first change is to insert in your code the line
    Please Login or Register  to view this content.
    It should go exactly after the line ...For each....

    This line by itself has no efect in your code. This is just a "mark" where you will send the action of the code later on.

    The second change I suggested is to replace your
    Please Login or Register  to view this content.
    with the following :
    Please Login or Register  to view this content.
    If your code was running before the changes, I cannot see why it could not work after this changes.

  5. #5
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Slight alteration/addition to my VBA code needed.

    Perhaps I didn't make myself clear.

    The first change is to insert in your code the line
    Please Login or Register  to view this content.
    It should go exactly after the line ...For each....

    This line by itself has no efect in your code. This is just a "mark" where you will send the action of the code later on.

    The second change I suggested is to replace your
    Please Login or Register  to view this content.
    with the following :
    Please Login or Register  to view this content.
    Again, this two lines have no virtual effect on your code, but having 2 buttons instead of one;
    this time if the user clicks on "Cancel" the code remains exactly as before, but if the user clicks on "Retry", the accion returns to where you put the "Jump" line and starts it over again.

    If your code was running before the changes, I cannot see why it could not work after this changes.

  6. #6
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: Slight alteration/addition to my VBA code needed.

    Hi Vichopalacious,

    Your code has worked perfectly thank you. It was the first part I was getting wrong, I didn't realise that the "Jump" needed to be inserted between the two lines that were already in my code. Sorry.

    Could I be cheeky and ask for your help one last time please?

    When an operator selects their initials, a message box appears with OK and Cancel. I would like the "Cancel" button when pressed to return to the form but not exit the code. I've tried that and it allows the operator to select any initial without the code asking for a password.

    I would like this because if the operator selected the wrong initials by mistake they can press "Cancel" and try again, without going through to the incorrect password stage.

    Thank you again for your help, it really is much appreciated.

    Kind Regards

    Dan

  7. #7
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Slight alteration/addition to my VBA code needed.

    Hi Dan

    Sorry for the late answer, I didn't see your new question

    First, I'm glad to know the initial part was solved.
    As I don't have your data, I can't see how your code works, I just try to imagine !

    When an operator selects their initials, a message box appears with OK and Cancel
    From your code, I don't see where this message could come from,
    perhaps if you post the workbook.....
    If you do so, please don't show sensitive data.

    Vicho

+ 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] Slight amendment needed to a ranking table.
    By gunnerterry in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-08-2013, 12:50 PM
  2. [SOLVED] Slight edit needed with code..
    By strud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2013, 03:50 AM
  3. [SOLVED] Slight edit needed - grouping x
    By strud in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2013, 07:47 AM
  4. Alteration needed: Sort sheets with cell value
    By amace87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2013, 02:46 PM
  5. [SOLVED] Slight alteration to code to work only on prefixed sheets
    By james 35 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-13-2013, 07:33 AM
  6. Slight addition to a long if statement
    By alias09 in forum Excel General
    Replies: 2
    Last Post: 11-23-2009, 03:41 PM
  7. slight tweek needed
    By khalid79m in forum Excel General
    Replies: 6
    Last Post: 04-04-2007, 08:56 AM

Tags for this Thread

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