Validate cell range
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Validate cell range

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    220
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi,
    Derek was so kind and wrote me the macro below and it is just what I need.

    Sometimes I would like to actually have a range from B5:B10 validated. How do I change to macro to achieve this.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If Target.Column = 2 Then
    If Target.Offset(0, -1) = "" Then
    MsgBox "You cannot enter data in Column B if the cell in Column A is blank"
    Target.Offset(0, 1).Select
    End If
    End If
    End Sub

    By the way I love the new forum setup with php.

    Thank you once again
    Andonny

  2. #2
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-04-09 15:49, andonny wrote:
    Hi,
    Derek was so kind and wrote me the macro below and it is just what I need.

    Sometimes I would like to actually have a range from B5:B10 validated. How do I change to macro to achieve this.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If Target.Column = 2 Then
    If Target.Offset(0, -1) = "" Then
    MsgBox "You cannot enter data in Column B if the cell in Column A is blank"
    Target.Offset(0, 1).Select
    End If
    End If
    End Sub

    By the way I love the new forum setup with php.

    Thank you once again
    Andonny
    Insert

    If Target.Row < 5 or Target.Row > 10 Then Exit Sub

    after the On Error Resume Next statement and you will bound the event region.

    HTH,
    Jay

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com