Results 1 to 6 of 6

Worksheet_Change - Error with nested If-then inside Case

Threaded View

  1. #1
    Registered User
    Join Date
    09-14-2010
    Location
    Park City, UT
    MS-Off Ver
    2010
    Posts
    19

    Worksheet_Change - Error with nested If-then inside Case

    Hello. I have an issue where Excel 2007 is crashing while running the following code. Here is what I ultimately want to achieve:

    In cell C18, I have a drop-down list with 4 values (5 if you include the default blank). Once the user selects from that list, I want VB code to analyze each cell in range H4:H33. If any of those cells are blank, then make the cell next to it blank else make it "no".

    Simply put, any time a user changes the value in C18, it should run the code once to make a select group of cells either "no" or blank.

    Option Explicit
    
    Sub Worksheet_Change(ByVal Target As Range)
    
    Application.ScreenUpdating = False
    
    Dim rngCellWithEventName As Range
    
    Set rngCellWithEventName = ActiveSheet.Range("C18")
    
    If ActiveCell = ActiveSheet.Range("C18") Then
        Select Case rngCellWithEventName
     	   Case "Athlete"
            	AthleteStuffToDo
        	Case "Culture":
        	Case "Event":
        	Case "SBM":
        	Case Else:      Exit Sub
        End Select
    End If
    
    Application.ScreenUpdating = True
    End Sub
    
    Function AthleteStuffToDo()
    Dim rngCellBeingChecked As Range
        For Each rngCellBeingChecked In Range("H4:H33")
            If rngCellBeingChecked.Value = "" Then
                rngCellBeingChecked.Offset(0, 1).Value = ""
            Else
                rngCellBeingChecked.Offset(0, 1).Value = "no"
            End If
        Next rngCellBeingChecked
    End Function
    Last edited by m1notaur; 09-24-2010 at 10:46 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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