+ Reply to Thread
Results 1 to 12 of 12

VB Change Function, worked but cursor keep spinning loading

  1. #1
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    VB Change Function, worked but cursor keep spinning loading

    Dear Experts,
    I wrote these syntax below, I found them worked, but my cursor keep spinning loading, never ended to end sub.
    At the end, I had to forcefully do 'crtl+alt+del' to close excel, otherwise cursor keep spinning loading endlessly.

    Anyone has any idea why it does so? I’m very gratefull for any help.
    Thank you very much

    My syntax in Sheet1 :

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1")) Is Nothing Then
    TryOut
    End If
    End Sub

    My syntax in Module :

    Sub TryOut ()
    with Sheets("sheet1").Range("A1")
    answer =.Value
    If Application.IsText(answer) Then
    MsgBox "Fill out with Number"
    .ClearContents

    ElseIf answer > 5 Or answer < 3 Then
    MsgBox "Fill out number that >3 or <5"
    .ClearContents

    Else
    MsgBox "That’s Correct"
    End If
    End with
    End Sub
    Last edited by bhayu; 05-24-2016 at 05:34 AM. Reason: mistext

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VB Change Function, worked but cursor keep spinning loading

    It's the .ClearContents lines. They are causing excel to just loop through both sets of codes without stopping because it never gets to the EndIf lines.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: VB Change Function, worked but cursor keep spinning loading

    Dear Expert (gmr4evr1),

    Thank you very much for your reply.

    How to ClearContent if the Sheets("sheet1").Range("A1") contain wrong answer?

    Thank you very much.
    Last edited by bhayu; 05-24-2016 at 10:10 PM.

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VB Change Function, worked but cursor keep spinning loading

    I've been trying to figure out a way to do that but haven't been able to yet. The problem is that when it clears the cell, it's considered a worksheet change so your Worksheet_Change code is triggered again and everything starts all over again.

  5. #5
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: VB Change Function, worked but cursor keep spinning loading

    Momentarily turn of the "Events" trigger i.e. Change is an event.

    Private Sub Worksheet_Change(ByVal Target As Range)
    With Sheets("sheet1").Range("A1")
    Application.EnableEvents = False
    .ClearContents
    Application.EnableEvents = True
    End With
    End Sub

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: VB Change Function, worked but cursor keep spinning loading

    BUILT IN TOOL FOR VALIDATION:

    Do you know that excel has built in feature for data validation ... On "Data Tab" check out "Data Validation".
    The "Data Validation" will clear the cell and give messages ... AND work even in WB's that do not have macros enabled

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VB Change Function, worked but cursor keep spinning loading

    Thanks for the assist nimrod. I wasn't sure if it would everything would work correctly if EnableEvents was places in the Worksheet_Change event, but I placed it in the TryOut sub and it worked.
    Bhayu,
    Here is the code with the EnableEvents added. See if it works for you..
    Please Login or Register  to view this content.
    Last edited by gmr4evr1; 05-25-2016 at 01:44 PM. Reason: Removed "Animation" from one of the EnableEvent lines

  8. #8
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: VB Change Function, worked but cursor keep spinning loading

    Hi gmr4evr1:
    Glad that worked out

    Bhayu should also check out excels built in validation feature as it does everything he's attempting to achieve without having to have a macro.

    Cheers

  9. #9
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VB Change Function, worked but cursor keep spinning loading

    I should probably check into it as well as I don't use it hardly at all.

  10. #10
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: VB Change Function, worked but cursor keep spinning loading

    BUILT IN DATA VALIDATION FEATURE:

    The built in data validation is quite robust . It allows you to form drop down lists, restrict values , clear fields for incorrect entries and provides 3 levels of messages : information, warning or error.

    Very easy to use AND with work even when the user does not have macro's enabled.

  11. #11
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: VB Change Function, worked but cursor keep spinning loading

    Dear Experts (gmr4evr1 and nimrod),

    Thank you very much for the reply and direction. May this thread also be an answer and direction for others.

    Actually I have known that excels built in validation feature, but I was still curious how to built it via Macro.

    Thank you very much for the assistance

    Best regards.

  12. #12
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VB Change Function, worked but cursor keep spinning loading

    You're welcome.

+ 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. Macro to change cursor looks
    By drowe005 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2015, 03:08 PM
  2. Create Spinning Pie Chart with a Macro support
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-19-2013, 04:17 AM
  3. Copy Formula On Range leaves wheel spinning
    By amartin575 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2013, 02:41 AM
  4. Spinning Roulette Wheel
    By bnitty in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2013, 07:26 PM
  5. [SOLVED] Cursor change during code execution
    By Geoff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2006, 07:10 PM
  6. Insert spinning button with time format in Excel 2000?
    By Pat Hughes in forum Excel General
    Replies: 5
    Last Post: 10-26-2005, 08:05 PM
  7. [SOLVED] Can I change the "white cross" cursor in Excel to another cursor?
    By KFEagle in forum Excel General
    Replies: 1
    Last Post: 05-03-2005, 03:06 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