+ Reply to Thread
Results 1 to 2 of 2

enable/disable a command button in User Form w/ condition

Hybrid View

  1. #1
    Registered User
    Join Date
    04-01-2014
    Location
    Burdwan, India
    MS-Off Ver
    Excel 2003
    Posts
    1

    enable/disable a command button in User Form w/ condition

    I like to enable/disable a command button in User Form with certain condition. I have worksheets like "ALL", "ALLA", "BARB" etc. I wrote the following code User Form Code window but it does not work. Please help me.

    Regards
    Bidyut

    Codes I wrote :
    Private Sub UserForm_load()
    With Worksheets("ALL")
    If WorksheetFunction.CountIf(Range("E2:E10000"), "ALLA") = 0 Then
    CommandButton1.Enabled = False
    Else
    CommandButton1.Enabled = True
    End If
    End With
    End Sub
    Last edited by vlady; 04-02-2014 at 01:02 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Post Re: enable/disable a command button in User Form w/ condition

    a "." seems to be missing in your code. Try:
    If WorksheetFunction.CountIf(.Range("E2:E10000"), "ALLA") = 0 Then
    the '.' is required to connect the Range "E2:E10000" to "ALL" worksheet.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 06-14-2013, 04:38 AM
  2. [SOLVED] Need assistance moving code from sample doc to actual doc
    By catt33 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-08-2012, 06:33 PM
  3. [SOLVED] follow up: the actual code
    By Sergei D in forum Excel General
    Replies: 0
    Last Post: 07-31-2006, 03:38 PM
  4. Replies: 1
    Last Post: 04-22-2006, 09:58 AM
  5. How do I get into the actual code for a macro??
    By andyd2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-18-2005, 09:31 PM

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