Consulting

Results 1 to 5 of 5

Thread: Stop user interaction with VBA

  1. #1

    Stop user interaction with VBA

    Hi guys,

    Im working on this macro that runs through a loop and checks the integrity of the cells in those records.

    The problem that im having is, when the loop runs, i would like to stop the user from being able to click on the cells in the sheet that are being validated (since this is causing some problems and the macro to crash).

    I do not want to protect the worksheet, since i would need to unprotect and protect the cells again everytime a cell value is changed/modified.

    Locking the sheet would be the same as well?

    At the moment, i have set the visibility of the workbook to false while this loops runs and back to true again when validation has completed.

    Any advice would be greatly appreciated, as usual!

    Cheers guys.


  2. #2
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    There is worksheet property that you can set to allow no selection of cells


    Sheets("Sheet1").EnableSelection = xlNoSelection

    then turn it back on when the procedure is done


    Sheets("Sheet1").EnableSelection =xlNoRestrictions
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  3. #3
    Quote Originally Posted by XLGibbs
    There is worksheet property that you can set to allow no selection of cells


    Sheets("Sheet1").EnableSelection = xlNoSelection

    then turn it back on when the procedure is done


    Sheets("Sheet1").EnableSelection =xlNoRestrictions
    Doesnt work without: UserIntefaceOnly

    If this helps anyone else, heres what i used.

    On
    [vba] Sheet1.Protect UserInterfaceOnly:=True
    Sheet1.EnableSelection = xlNone
    [/vba]

    [vba] Sheet1.Protect UserInterfaceOnly:=False
    Sheet1.EnableSelection = xlNoRestrictions
    [/vba]

    Thanks for the help XLGibbs.
    Appreciate it dearly.

  4. #4
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location
    If you want to block all keyboard, mouse and other apps to Excel (you can
    still imput to dialog boxes) you could use this:
    [VBA]Application.Interactive = False[/VBA]

    To revert back to normal:
    [VBA]Application.Interactive = True[/VBA]

    Marcster.

  5. #5
    Quote Originally Posted by Marcster
    If you want to block all keyboard, mouse and other apps to Excel (you can
    still imput to dialog boxes) you could use this:
    [vba]Application.Interactive = False[/vba]

    To revert back to normal:
    [vba]Application.Interactive = True[/vba]

    Marcster.
    Thanks Marcster,

    Ill keep that in mind.

    Appreciate it!

Posting Permissions

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