+ Reply to Thread
Results 1 to 3 of 3

Disable command button

Hybrid View

  1. #1
    Registered User
    Join Date
    04-20-2005
    Posts
    52

    Question Disable command button

    I have a command button that I have disabled unless a certain number is entered.
    but I need it disabled also if the cell is blank any ideas.

    Here is the code thus far.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Sheets("Quality Accessing Template").Range("B6").Value >= 0 And Sheets("Quality Accessing Template").Range("B6").Value <= 9999 Then
    Sheets("Quality Accessing Template").CommandButton1.Enabled = True

    Else

    Sheets("Quality Accessing Template").CommandButton1.Enabled = False

    End If


    End Sub

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Sheets("Quality Accessing Template").Range("B6").Value >= 0 And Sheets("Quality Accessing Template").Range("B6").Value <= 9999 And Sheets("Quality Accessing Template").Range("B6") <> "" Then

    Sheets("Quality Accessing Template").CommandButton1.Enabled = True

    Else

    Sheets("Quality Accessing Template").CommandButton1.Enabled = False

    End If

    End Sub



    Mangesh

  3. #3
    Bob Phillips
    Guest

    Re: Disable command button

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    With Sheets("Quality Accessing Template")
    If Not IsEmpty(.Range("B6").Value) Then
    If .Range("B6").Value >= 0 And _
    .Range("B6").Value <= 9999 Then
    .CommandButton1.Enabled = True
    Else
    .CommandButton1.Enabled = False
    End If
    Else
    .CommandButton1.Enabled = False
    End If
    End With
    End Sub

    --
    HTH

    Bob Phillips

    "Mikeice" <Mikeice.1qrguc_1118995503.4983@excelforum-nospam.com> wrote in
    message news:Mikeice.1qrguc_1118995503.4983@excelforum-nospam.com...
    >
    > I have a command button that I have disabled unless a certain number is
    > entered.
    > but I need it disabled also if the cell is blank any ideas.
    >
    > Here is the code thus far.
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    >
    > If Sheets("Quality Accessing Template").Range("B6").Value >= 0 And
    > Sheets("Quality Accessing Template").Range("B6").Value <= 9999 Then
    > Sheets("Quality Accessing Template").CommandButton1.Enabled = True
    >
    > Else
    >
    > Sheets("Quality Accessing Template").CommandButton1.Enabled = False
    >
    > End If
    >
    >
    > End Sub
    >
    >
    > --
    > Mikeice
    > ------------------------------------------------------------------------
    > Mikeice's Profile:

    http://www.excelforum.com/member.php...o&userid=22467
    > View this thread: http://www.excelforum.com/showthread...hreadid=380000
    >




+ 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