Deactivate worksheet code during paste
Deactivate worksheet code during paste
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Deactivate worksheet code during paste

  1. #1
    Board Regular swaink's Avatar
    Join Date
    Feb 2002
    Location
    51.421818,-0.977139
    Posts
    432
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi All
    I have code in a worksheet that highlights the entire row when the user selects a cell.

    However when I try to paste new data to that sheet using a macro the macro fails because of the active worksheet code.

    Is it possible to suspend the worksheet code whilst another macro is running then re activate it on completion?

    Many thanks

    Kevin

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Perth Australia
    Posts
    1,579
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi
    Yes, you need to put a condition at the beginning of the code such as:
    If Range("A1").Value = 77 Then
    (rest of code)
    End If (add this after your code)

    Then it will only be active whilst the value of A1 is 77 (or whatever you choose)

    hope this helps
    regards
    Derek

  3. #3
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-22 03:03, swaink wrote:
    Hi All
    I have code in a worksheet that highlights the entire row when the user selects a cell.

    However when I try to paste new data to that sheet using a macro the macro fails because of the active worksheet code.

    Is it possible to suspend the worksheet code whilst another macro is running then re activate it on completion?

    Many thanks

    Kevin

    Application.enableevents=false

    then the rest of your code....

    application.enableevents=true


    ivan

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Perth Australia
    Posts
    1,579
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Ivan, that's much neater than mine
    regards
    Derek

  5. #5
    Board Regular swaink's Avatar
    Join Date
    Feb 2002
    Location
    51.421818,-0.977139
    Posts
    432
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thats fantastic guys many many thanks

    Regards

    Kevin

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com