+ Reply to Thread
Results 1 to 3 of 3

Excel 2003 Private Sub Not Working

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Plymouth, SW England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Excel 2003 Private Sub Not Working

    I have a spreadsheet in which I have a number of columns where information is entered. What I’m trying to achieve is that when a valuein one column is chosen an answer is forced to be entered in an adjacent columnand and that no further information can be entered until this column is filled. The columns in question are D and E. In the D column there is a drop down list from which a response is either ‘YES’ or ‘NO’. If ‘NO’ is chosen a reason has to be entered into the adjacent cell, e.g if ‘NO’ is entered in Cell D3 a reason MUST BE entered in E3 before any further cells can be completed. The code I’m using at the moment and doesn’t seem to be working is as follows:

    Private Sub Worksheet_SelectionChange(ByVal Target AsRange)
    Dim myCell As Range
    Dim myRange As Range
    On Error GoTo NoRange
    If Range("D3:102").Value = “NO” Then
    If Range(“E3:E102”). Value = “########” then (I’massuming I’m using the right symbol for text)
    Exit Sub
    Set myRange = Range("E3:E102")
    For Each myCell In Range("D3:102")
    If myCell.Value = "NO" Then
    If myRange.Value =”” then
    MsgBox (“You must enter a reason why a 48 Hour Responsehas not been sent”), vbCritical, “Reason for Non-Dispatch Required”
    Application.EnableEvents = False
    myCell.End(xlToRight).Offset(0,1).select
    Application.EnableEvents = True
    Exit Sub
    End If
    Next myCell
    NoRange:
    Application.EnableEvents = True
    End if
    End If
    End Sub

    Many thanks in advance for your help

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel 2003 Private Sub Not Working

    perhaps
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    04-22-2013
    Location
    Plymouth, SW England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel 2003 Private Sub Not Working

    JosephP many thanks this worked a treat.

    Very much appreciated.

+ Reply to Thread

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