+ Reply to Thread
Results 1 to 2 of 2

Why does my code not get run/called?

  1. #1
    Registered User
    Join Date
    01-25-2005
    Posts
    8

    Unhappy Why does my code not get run/called?

    Well here is my code that someone helped me out with, however it never gets called. I thought all i had to do was right click on my worksheet tab, view code, and paste. Could someone pleaze help me out.

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo Finish

    If Left(Target.Address, 2) = "$A" Then
    Select Case UCase(Target.Value)
    Case "STR"
    Target.EntireRow.Font.ColorIndex = 43
    Case "LTR"
    Target.EntireRow.Font.ColorIndex = 41
    Case "SGE"
    Target.EntireRow.Font.ColorIndex = 3
    Case Else
    Target.EntireRow.Font.ColorIndex = 0
    End Select
    End If

    Finish:

    Application.EnableEvents = True

    End Sub

    This will work on any change to a cell in Col A. You didn't specify where the changes occur so change the IF statement to suit. This code needs to be pasted in the sheet code section (right click on the sheet tab and select 'view code')

  2. #2
    Forum Contributor
    Join Date
    01-11-2004
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    388
    Hi!

    Runs for me but:

    I took out the on error goto finish. With a thing like that in the script you'll never find what goes wrong because "nothing" happens, apparently.

    I prefer if target.row=1 then.

    If you are interested in application.enableevents, I guess you need to disable them first so you can re-enable them later.

    I can't really tell if it works because I am not entirely certain what you want it to do. Can you amplify?

    Alf

+ Reply to Thread

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.6.0 RC 1