+ Reply to Thread
Results 1 to 4 of 4

How can I make a cell mandatory and only accept a Y or N?

Hybrid View

  1. #1
    Vicki
    Guest

    How can I make a cell mandatory and only accept a Y or N?

    I would like to make a cell mandatory, but in the event that I can't do that
    I would still like to be able to only have a choice of Y or N.

  2. #2
    Ron Rosenfeld
    Guest

    Re: How can I make a cell mandatory and only accept a Y or N?

    On Thu, 23 Jun 2005 07:32:04 -0700, "Vicki" <Vicki@discussions.microsoft.com>
    wrote:

    >I would like to make a cell mandatory, but in the event that I can't do that
    >I would still like to be able to only have a choice of Y or N.


    You could use an event macro to do both.

    You may want to specify a particular worksheet if your workbook has multiple
    sheets, though.

    To enter this code, right click on the sheet tab and select View Code. Then
    paste the code below into the window that opens.

    Change the "c" reference to the appropriate cell.

    Note that, as written, Y or N must be entered in upper case. Obviously this
    can be changed if such is not your intent.

    ======================
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim c As Range

    Set c = Range("A1")

    Application.EnableEvents = False

    If c.Text <> "Y" And c.Text <> "N" Then
    Application.Goto reference:=c, scroll:=True
    MsgBox ("Must Enter ""Y"" or ""N"" in A1")
    End If

    Application.EnableEvents = True
    End Sub
    ========================
    --ron

  3. #3
    Ron Rosenfeld
    Guest

    Re: How can I make a cell mandatory and only accept a Y or N?

    On Thu, 23 Jun 2005 07:32:04 -0700, "Vicki" <Vicki@discussions.microsoft.com>
    wrote:

    >I would like to make a cell mandatory, but in the event that I can't do that
    >I would still like to be able to only have a choice of Y or N.


    You could use an event macro to do both.

    You may want to specify a particular worksheet if your workbook has multiple
    sheets, though.

    To enter this code, right click on the sheet tab and select View Code. Then
    paste the code below into the window that opens.

    Change the "c" reference to the appropriate cell.

    Note that, as written, Y or N must be entered in upper case. Obviously this
    can be changed if such is not your intent.

    ======================
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim c As Range

    Set c = Range("A1")

    Application.EnableEvents = False

    If c.Text <> "Y" And c.Text <> "N" Then
    Application.Goto reference:=c, scroll:=True
    MsgBox ("Must Enter ""Y"" or ""N"" in A1")
    End If

    Application.EnableEvents = True
    End Sub
    ========================
    --ron

  4. #4
    Ron Rosenfeld
    Guest

    Re: How can I make a cell mandatory and only accept a Y or N?

    On Thu, 23 Jun 2005 07:32:04 -0700, "Vicki" <Vicki@discussions.microsoft.com>
    wrote:

    >I would like to make a cell mandatory, but in the event that I can't do that
    >I would still like to be able to only have a choice of Y or N.


    You could use an event macro to do both.

    You may want to specify a particular worksheet if your workbook has multiple
    sheets, though.

    To enter this code, right click on the sheet tab and select View Code. Then
    paste the code below into the window that opens.

    Change the "c" reference to the appropriate cell.

    Note that, as written, Y or N must be entered in upper case. Obviously this
    can be changed if such is not your intent.

    ======================
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim c As Range

    Set c = Range("A1")

    Application.EnableEvents = False

    If c.Text <> "Y" And c.Text <> "N" Then
    Application.Goto reference:=c, scroll:=True
    MsgBox ("Must Enter ""Y"" or ""N"" in A1")
    End If

    Application.EnableEvents = True
    End Sub
    ========================
    --ron

+ 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