• Change Event (2002)

    Author
    Topic
    #411194

    I am using the Worksheet Change event for any cell that is modified in the worksheet. I have the following simple code in the event:

    If target.value =

    Viewing 3 reply threads
    Author
    Replies
    • #889647

      The idea would be to loop through all cells in the Target range, but testing for any cell in a worksheet is a rather tall order. You could do something like this:

      Dim oCell As Range
      For Each oCell In Intersect(Me.UsedRange, Target)
      If oCell.Value = “” Then …
      Next oCell

      This limits the loop to those cells in the Target range that fall within what Excel considers to be the used range of the worksheet (referred to as “Me”).

      • #889714

        Thank you Hans! The me.usedrange came in very handy. Legare’s solution would also work but the me.usedrange also allows me to update mutiples cells at once via ctrl+enter and still execute the code in the change event. Thanks again.

      • #889715

        Thank you Hans! The me.usedrange came in very handy. Legare’s solution would also work but the me.usedrange also allows me to update mutiples cells at once via ctrl+enter and still execute the code in the change event. Thanks again.

    • #889648

      The idea would be to loop through all cells in the Target range, but testing for any cell in a worksheet is a rather tall order. You could do something like this:

      Dim oCell As Range
      For Each oCell In Intersect(Me.UsedRange, Target)
      If oCell.Value = “” Then …
      Next oCell

      This limits the loop to those cells in the Target range that fall within what Excel considers to be the used range of the worksheet (referred to as “Me”).

    • #889649
          If Target.Count > 1 Then Exit Sub
      
    • #889650
          If Target.Count > 1 Then Exit Sub
      
    Viewing 3 reply threads
    Reply To: Change Event (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: