+ Reply to Thread
Results 1 to 4 of 4

How to run two macro different on different clicks on same button

  1. #1
    Forum Contributor
    Join Date
    01-07-2014
    Location
    chandigarh
    MS-Off Ver
    Excel 2010
    Posts
    122

    Question How to run two macro different on different clicks on same button

    Hi Friends,
    I got a 2 commands in one VBA which I want to run in same button but I wish that on one click only one command should run and on second click on same button second command should run. For your better understanding I have pasted the code also, this code carries two different functions one is to strikeoff the text in cell and another will undo the strike off.
    Now I want that when I clicked the Commandbutton it strikeoff the text of cell but when I again click on the same button it undo the same strikeoff.

    Can it be possible ?
    If YES than please can you amend the codes and make it as I mentioned above.



    Macro Are As Follow:

    Private Sub CommandButton5_Click()
    ActiveCell.Select
    With Selection.Font
    .Strikethrough = True
    End With
    ActiveCell.Select
    With Selection.Font
    .Strikethrough = False
    End With
    End Sub

    Thanks For Reading The Post.

    Regards,

  2. #2
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: How to run two macro different on different clicks on same button

    Hello
    The easiest way would be to use a Toggle Button rather than a Command. For example, with the Active Cell:

    Please Login or Register  to view this content.
    Hope this helps.
    DBY

  3. #3
    Forum Contributor
    Join Date
    01-07-2014
    Location
    chandigarh
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: How to run two macro different on different clicks on same button

    Quote Originally Posted by DBY View Post
    Hello
    The easiest way would be to use a Toggle Button rather than a Command. For example, with the Active Cell:

    Please Login or Register  to view this content.
    Hope this helps.

    DBY
    Hi DBY
    Thanks for the reply, your idea was very helpful, it resolved my query and this thread

    Thank You So Much Once Again !!

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: How to run two macro different on different clicks on same button

    Hello warriorpoet7176,

    I am happy to see that your issue had been solved, however, in future please do remember to add Code Tags when posting any Code.


    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    Thank you.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ 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. Auto sum for a cell, when diferrent button clicks.
    By Begineer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2016, 09:54 PM
  2. can vba clicks userform button
    By sujithy007 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-22-2013, 02:35 AM
  3. Disable Button after 3 clicks
    By MrBill in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2013, 07:25 PM
  4. Button Macro for counter to check nos of clicks
    By sashavibes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2011, 07:49 AM
  5. Count of button clicks
    By rateesh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2010, 01:38 PM
  6. [SOLVED] Button clicks and textbox Exit events
    By Linc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-26-2005, 07:25 PM
  7. Why 2 clicks on a command button
    By cush in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2005, 03:06 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