+ Reply to Thread
Results 1 to 11 of 11

Command Button Macro

  1. #1
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Command Button Macro

    Hello guys,



    Would you all give me a formula for command button “Loss”, automatically “C21″ become “100,000″. and "Others" become "Free". Also "VIP Lounge", "C13" become VIP Lounge.

    Also what is formula for command button “Refresh”, and automatically clear C9,C13, C14:C18,C21 ?

    Thank you all in advance.

    Attached Images Attached Images

  2. #2
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Command Button Macro

    If you're sure that you have command buttons and you need VBA only, code for button "Loss" would be like :

    Please Login or Register  to view this content.
    Then, format your C21 cell to number, and give it 3 decimal number places to display 100,000.

    You can do same way for all other cells, just change values.

    For refresh :

    Please Login or Register  to view this content.
    And then repeat for all others, that's one option.

    P.S. : to me It looks like you have just cells with thick border and not CmdButtons, maybe you should provide a sample here, picture doesn't tell much without file.
    Last edited by Lukael; 08-09-2014 at 07:59 AM.

  3. #3
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Re: Command Button Macro

    Dear Lukael,

    Thanks for your reply, it works man.

    Following the questions, please find the file.

    Additional help, would you please give me some macro formulas for "Other" on C19 to change C21 & B12 (sheet 2) become "Free". "Blue refresh picture" to clear automatically all C9,C13, C14:C18,C21, and "print picture" to print all in sheet 2.

    Many thanks.
    Attached Files Attached Files
    Last edited by MyBoyBriant; 08-09-2014 at 07:03 PM.

  4. #4
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Command Button Macro

    here, try this sample. Don't have a printer now so you might take a try first.

    And you need to have a macro-enabled workbook (.xlsm) for all that working, sample you provided was not.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Re: Command Button Macro

    It works for "Clear" and "Print".

    But how about the macro formulas for "Other" on C19 when clicked it will change C21 & B12 (on Sheet 2) become "Free".. And when "VIP Lounge" on C11 clicked, the C12 become text "VIP Lounge" ?

    Im such a beginner in VB.. Really appreciate your help.

  6. #6
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Command Button Macro

    But how about the macro formulas for "Other" on C19 when clicked it will change C21 & B12 (on Sheet 2) become "Free"..
    I thought you wanted to do this, or I don't understand you. As you said or I understand, you needed macro for button "other" - when you click It, c21 & b12 on sheet2 must have text value "Free". Maybe you want something else ?

    VIP lounge - didn't do nothing there, only what you asked. Maybe you had that before.

  7. #7
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Re: Command Button Macro

    Its all done.. with all this formula below:

    Sub Rectangle6_Click()
    Range("c21").Value = 50000
    Range("c20").Value2 = "Loss"
    End Sub
    Sub Rectangle7_Click()
    Range("c21").Value = 50000
    Range("c20").Value2 = "Broken"
    End Sub
    Sub Rectangle8_Click()
    Range("c21").Value = "Free"
    Range("c20").Value2 = "Others"
    End Sub
    Sub Rectangle1_Click()
    Range("c12").Value = "VIP Lounge"
    End Sub
    Sub Rectangle5_Click()
    Range("c12").Value = "Main Lobby"
    End Sub
    Sub Rectangle4_Click()
    Range("c12").Value = "AOS"
    End Sub
    Sub MyPrint()
    Sheet2.PrintOut
    End Sub
    Sub ClearButton_Click()
    Range("C9").ClearContents
    Range("C13").ClearContents
    Range("C14:C18").ClearContents
    Range("C21").ClearContents
    End Sub


    But why after i save as Excel Macro Enabled and closed it, every time i opened it back it doesnt working? It said that macro may not available..
    How should i save it or how to open it?

  8. #8
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Command Button Macro

    But why after i save as Excel Macro Enabled and closed it, every time i opened it back it doesnt working? It said that macro may not available..
    Go to Excel icon in upper left, and go to Excel options>Trust center>Trust center settings>macro settings and enable all macros. Close and re-open Excel, now macros will work.....You probably missed that.

    How should i save it or how to open it?
    No matter how you open, but save in .xlsm for macros. And wherever you open It, make sure PC's Excel is enabled for macros as I told you.

  9. #9
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Re: Command Button Macro

    It didnt work!

    Already set enable macro in trust setting.. but this notification keep coming like these attached pics.

    Why? i really dont understand this.
    Attached Images Attached Images

  10. #10
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Re: Command Button Macro

    It didnt work..
    Attached Images Attached Images

  11. #11
    Registered User
    Join Date
    08-09-2014
    Location
    Jakarta, Indonesia
    MS-Off Ver
    2007
    Posts
    6

    Re: Command Button Macro

    Its solved!
    I just find this link http://support.microsoft.com/kb/927150

    Many thanks to you, Lukael. Youre so helpful. I really appreciate that!

  12. #12
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Command Button Macro

    Glad you solved. You're welcome

    Mark thread as 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. [SOLVED] Command Button with macro
    By GJR in forum Excel General
    Replies: 3
    Last Post: 03-24-2014, 01:53 PM
  2. Command button macro
    By majorpun in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2011, 02:24 AM
  3. macro will not run on command button
    By SRJ2665 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2009, 09:58 AM
  4. Replies: 1
    Last Post: 09-17-2007, 09:57 PM
  5. Replies: 0
    Last Post: 11-03-2005, 11:00 AM

Tags for this Thread

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