+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    02-23-2010
    Location
    Philadelphia,USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Unhappy Screen Flickering Even With VBA codes

    Hi Anyone!

    I'm Using the following code in my workbook's sheet. I use this code to double click and change the values to what I want and also to change my serial number in H8 and H9 according to the date.

    But when I use the code the screen flickers. I'm Using Excel 2007.

    I have tried many ways to get rid of this. But everything has failed.

    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    Application.ScreenUpdating = False
        
        If Not Intersect(Target, Range("G4:G14")) Is Nothing Then ' You can Change the range here
            
            Cancel = True
            
            With Target
                .Font.Name = "Wingdings"
                .Font.Size = 20
                .HorizontalAlignment = xlCenter
            End With
          
            If Target.Value = "þ" Then
                Target.Value = "ý"
                
            Else
                Target.Value = "þ"
            End If
        
        End If
        
        
        If Not Intersect(Target, Range("J7:J7")) Is Nothing Then
            Cancel = True
            If Target.Value = "OUT" Then
                Target.Value = "IN"
                
            Else
                Target.Value = "OUT"
            End If
        End If
        
        If Not Intersect(Target, Range("F8:F8")) Is Nothing Then
            Cancel = True
            If Target.Value = "INSURED" Then
                Target.Value = "NOT INSURED"
                
            Else
                Target.Value = "INSURED"
            End If
        End If
        
            If Not Intersect(Target, Range("D7:D7")) Is Nothing Then
            Cancel = True
            If Target.Value = "Cash" Then
                Target.Value = "Credit"
                
            Else
                Target.Value = "Cash"
            End If
        End If
        
        If Not Intersect(Target, Range("J8:J8")) Is Nothing Then
            Cancel = True
            If Target.Value = "Foreigner" Then
                Target.Value = "Local"
                
            Else
                Target.Value = "Foreigner"
            End If
       End If
       Application.ScreenUpdating = True
       End Sub
    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim oCell As Range
      If Not Intersect(Target, Range("H8:H9")) Is Nothing Then
        Application.EnableEvents = False
        For Each oCell In Intersect(Target, Range("H8:H9"))
          If IsNumeric(oCell) And Not oCell = "" Then
            oCell = Format(oCell, "0000") & " / " & Format(Now(), "yy")
          End If
        Next oCell
        Application.EnableEvents = True
      End If
    End Sub
    Can anybody find me an alternative to stop the flickering.

    Regards
    Fiza

  2. #2
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: Screen Flickering Even With VBA codes

    you havent got
    Code:
    Application.ScreenUpdating = True/false
    in the second sub
    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0