+ Reply to Thread
Results 1 to 4 of 4

Greyed-out Buttons

Hybrid View

joewood86 Greyed-out Buttons 07-04-2008, 07:37 AM
royUK It depends where you got the... 07-04-2008, 07:41 AM
dominicb Good afternoon joewood86 ... 07-04-2008, 07:59 AM
joewood86 Thanks 07-04-2008, 11:41 AM
  1. #1
    Registered User
    Join Date
    07-04-2008
    Location
    England
    Posts
    3

    Greyed-out Buttons

    Hi

    I'm fairly new to Excel Macroing and I've develeoped a spreadsheet which produces a report based on the information contained within a row. The user selects the row they want to make a report for, then click a button which runs a macro to copy the contents to each cell into a sheet called "Report", which has the layout of the report I print. The macro also opens Word and copies the cells which contain the report information into a blank document, then saves it with a sequential file name, before closing Word.

    Is it possible to have the "Make Report" button greyed-out unless a specific field has been filled in? Essentially when the user selects the row they want to make the report for I want the macro to check if a specific cell within that row is blank or not, and if it is blank the "Make Report" button should be grey.

    Any ideas?

    Joe

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It depends where you got the button from - the Forms toolBar or Controls toolBox. they work differently.

    Also, I would think that the report could be filled simply by using VLOOKUP
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon joewood86

    If you are using buttons from the Control Toolbox toolbar, then something like this would toggle the state of the .Enabled property for CommandButton1, depending on whether cell A1 was filled or not :

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("A1") = "" Then
    ActiveSheet.OLEObjects("CommandButton1").Object.Enabled = False
    Else
    ActiveSheet.OLEObjects("CommandButton1").Object.Enabled = True
    End If
    End Sub
    This needs to go in the relevant sheet's event procedure module.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Registered User
    Join Date
    07-04-2008
    Location
    England
    Posts
    3

    Thanks

    Hi

    I've got it sorted now, through the code that DominicB and from royUK's advice I've used a Message Box to say that the field must be completed to create a report. The whole thing works with one big if statement and if the box isn't complete the rest of the macro is ignored.

    Many thanks for your help and advice

    Joe

+ 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