+ Reply to Thread
Results 1 to 15 of 15

create a button in excel with macros or VBA code in a specific cell targets.

  1. #1
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    create a button in excel with macros or VBA code in a specific cell targets.

    Hi Team,

    I have created a individual tracker spread sheet in each user system and on the spread sheet I have inserted 2 buttons in 1st sheet. when employee wants to take a break he has to click on the log out button and when he came back he needs to click on login button. I have another sheet named "timings" and I have created 2 columns, one is login and another is logout. What I need is when user click on the login button, the system time and date to be auto update under login column and when he clicks on logout button the system time and date to be auto update under logout column.

    I have attached the file for your reference. Please advise on creating macro or VBA code. Thanks.

    Regards,
    Girish
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    You can easily do it with one button:

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Thank you very much it's worked, but still I need the below thing to be include on the macro code. Please help. Thanks.

    1. you have created macro that if i click the button the date and time will auto update in sheet2 but what I need is the time and date to be auto update in specific sheet, eg: i have created a sheet named break, so time and date need to be auto update on that break sheet.

    2. once user click on that button the file should auto save along with the date and time updation.

    3. will it possible to hide the macro code for the button.

    Kindly do the needfull.....

    Regards,
    Girish

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Okay, so change the code a little:
    Please Login or Register  to view this content.
    To 'hide' the macro code, simply lock your VBA project in the VBE: Tools > VBAProject Properties > Protection > tick Lock project for viewing (with optional password)

  5. #5
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Hi Olly,

    Thank you very much it helped me lot. But I need one more help from you. I need to create one more button which should for login and logout. As per your instruction I have created a button for break and unbreak, for break things date and time will auto update in 2 & 3 column. What I need to when employee login to office he has to click on login button and date and time to be auto update on A column at the start of the day and when he need to go home he has to click on log out and date& time to be update at the end of unbreak time in D column. please find the example below for your reference and also file attached. Kindly do the needful. Thanks.

    login Break Unbreak logout

    11-07-2014 04:00 11-07-2014 06:00 11-07-2014 07:00
    11-07-2014 07:10 11-07-2014 07:15
    11-07-2014 09:00 11-07-2014 09:15
    11-07-2014 12:00 11-07-2014 12:30 11-07-2014 13:00

    Regards,
    Girish
    Attached Files Attached Files

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Name your buttons btLogin and btBreak respectively, then use this:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Sorry, I am not getting any inputs by using the above given 2 codes in to 2 buttons. Please advise. Thanks.

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Quote Originally Posted by Giri.hb View Post
    Sorry, I am not getting any inputs by using the above given 2 codes in to 2 buttons. Please advise. Thanks.
    Attach your workbook, so I can see what you've tried, and advise you what to fix.

    Sorry, I can't upload a workbook from this network...

  9. #9
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Please attach the file or send it to my email id [email protected]

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Already explained I can't upload files from this network. I won't be sending any emails to you.

    Attach your workbook here so I can see what you've tried, and I can help you fix it. Or not. Up to you.

  11. #11
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Hi Team,

    Please find the attached file for your reference that I have inserted the code as your provided for 2 buttons. Please check and advise. Thanks.

    Regards,
    Girish
    Attached Files Attached Files

  12. #12
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Okay - you've created MSForm buttons, instead of ActiveX buttons, as you were originally using. Easiest way to make my code work is to add two ActiveX buttons, one named btBreak, the other named btLogin.

    I'm on home network now, so can upload files - see corrected attachment.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Hi Olly,

    I have tried but still I am not able to create the buttons. I have attached the screen shot that how I have inserting the button. Please check and advise and also let us know if their any way that I can learn VBA macros from basic.
    please its my personal request.

    Regards,
    Girish
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    Hi Team,

    Can you please some one assist me on the above concern. Thanks.

    Regards,
    Girish

  15. #15
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: create a button in excel with macros or VBA code in a specific cell targets.

    You have created ActiveX buttons, but you have changed the CAPTION, not the NAME. Right click the button and click 'Properties', then change the NAME to btBreak / btLogin...

    Look at the file I attached on 12th July - look at the properties of the two ActiveX buttons on that sheet.

+ 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] How to create a macros that will name a range taking the value of a specific cell?
    By erkamu in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-05-2014, 07:12 AM
  2. Create A Button In Document To Disable/Enable A Specific Line of Code
    By BLK306 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-05-2014, 02:12 PM
  3. vb code for receive button to substract textBox value from specific cell of sheet
    By swapbhay in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-21-2013, 09:28 AM
  4. How to create a command button to send specific cells out of an excel sheet..
    By meltelawi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2013, 05:25 PM
  5. Create a button to enable macros
    By dwarford101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2010, 05:26 AM

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