+ Reply to Thread
Results 1 to 5 of 5

Command button Enable using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    11-05-2006
    Posts
    11

    Command button Enable using VBA

    Hi,

    On my excel sheet I have a button named Button14. I want to control if the button is enabled by comparing the contents of values in cells C25 and E25.

    I have created another button named button50. In the click property of this button, I have written the following code:

    Sub Button50_Click()

    If [C25].Value = [E25].Value Then
    Button14.Visible = True
    Else
    Button14.Visible = False
    End If

    End Sub

    In excelsheet, when I click on Button50, it gives me an error "Runtime error 424" - object required. In debug mode, the highlighter in on the line
    " Button14.Visible = True" from the above code.

    Can someone help me in identifying what is it that I am doing wrong?

    Thanks in advance.

    Warm regards,
    --Prasad

    ps: Is there any way I can find out the "name" of the commnad button which I have already created and then renamed its text later?

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    try this

    If range("C25").Value = range("E25").Value Then

  3. #3
    Registered User
    Join Date
    09-20-2006
    Location
    Poland
    Posts
    46
    Hi,

    Quote Originally Posted by psatkar
    In excelsheet, when I click on Button50, it gives me an error "Runtime error 424" - object required.
    Your code should work, error 424 indicates that VBA cannot find Button14 - maybe there is a typo in the name of the button or in your code. Are Button50 and Button14 placed in the same worksheet? If not, you should reference a button along with worksheet name like: Sheet2.Button14.Visible=True.
    Last edited by Bartek; 11-10-2006 at 05:03 AM.
    MS Excel Games Library and much more:
    http://www.dzikosoft.com/gmexcel

  4. #4
    Registered User
    Join Date
    11-05-2006
    Posts
    11
    Is there any way I can find the name of the command button which I ahve created in worksheet.

    I wanted to confirm the name of button Button14.

    Warm regards,
    --Prasad

  5. #5
    Forum Contributor
    Join Date
    09-04-2006
    Location
    Yorkshire, England
    Posts
    267
    Just put the excel sheet in design mode and look under the buttons properties
    JR
    Versions
    Mac OS X 'Leopard'
    Mac MS Office Excel 2004
    Windows XP
    MS Excel 2002
    MS Excel 2003

+ 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