Consulting

Results 1 to 7 of 7

Thread: Click Event

  1. #1
    VBAX Regular
    Joined
    Jun 2010
    Posts
    7
    Location

    Click Event

    In VBA, how do you put a click event on a spreadsheet where you click the command button once and the spreadsheet minimizes and you click the button again and it maximizes? Thanks.

    jbbman

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If the spreadsheet minimizes, how are you going to then click the button?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    Where do you intend to hide the button? If the button resides on the sheet that you minimise, it dissappears with the sheet.
    Last edited by Aussiebear; 06-28-2010 at 02:37 PM. Reason: Beaten to it by quick draw Mcgraw (XLD)
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    VBAX Regular
    Joined
    Jun 2010
    Posts
    7
    Location

    Thumbs down Good Point

    You made a good point. It's really the concept of using one command button to do two things. You could switch between normalizing and maximizing the spreadsheet/window. It doesn't even have to be a window or spreadsheet, it could be bolding or unbolding a cell.

    I thought I saw , I could be mistaken, a command button that used If...Then statement with the vba not operator to do turn something on and off like a boolean switch. The first click enabled the command and the second disabled the command, like a light switch. Thanks.

    P.S. Couldn't the command button be placed on a form, At least with the spreadsheet?

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You mean something like

    [vba]

    With Activecell.Font

    .Bold = Not .Bold
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA] With Application
    If .WindowState = xlNormal Then
    .WindowState = xlMaximized
    Else
    .WindowState = xlNormal
    End If
    End With[/VBA]

    Using Not is something like this, where there can only be two states

    [VBA]
    ActiveCell.Font.Bold = Not ActiveCell.Font.Bold

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular
    Joined
    Jun 2010
    Posts
    7
    Location
    Thank you thank you. That's it. Sorry for the trouble.
    -jbbman

Posting Permissions

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