Insert checkbox using button
Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: Insert checkbox using button

  1. #21
    Board Regular
    Join Date
    Sep 2015
    Location
    El Paso, TX
    Posts
    87
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Insert checkbox using button

    Quote Originally Posted by My Aswer Is This View Post
    So tell me. When you double click on what cell?
    You want that cells background color to be what color say like red blue green yellow
    And enter todays date in what cell.


    I need you to say something like this:

    When I double click on any cell in column B to turn that cells background color to yellow and put todays date in column A

    Do not say when I double click on column address.

    When i double click on any cell on columns G, H, or I, turn that cell blue and insert todays date and time in to that same cell.

    Like that?

  2. #22
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,730
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Insert checkbox using button

    Try this:
    OK. If some one double clicks on column G H or I this script will run.

    This is an auto sheet event script
    Your Workbook must be Macro enabled
    To install this code:
    Right-click on the sheet tab
    Select View Code from the pop-up context menu
    Paste the code in the VBA edit window
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    'Modified 4-11-18 8:35 PM EDT
    If Not Intersect(Target, Range("G:I")) Is Nothing Then
    Cancel = True
    If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
    Cells(Target.Row, Target.Column).Value = Date
    Cells(Target.Row, Target.Column).Interior.Color = vbBlue
    End If
    End Sub
    Last edited by My Aswer Is This; Apr 11th, 2018 at 08:38 PM.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  3. #23
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,730
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Insert checkbox using button

    Now this may not be what you want because I asked what cell and you said G H Or I

    Well are all three of these cells now empty?
    Because if you double click on G and G already has data the date is now going to over write the data in the cell.

    And I'm surprise would want to see a date in column G on one row and then see a date in column H on another row and then maybe a date in another column of another row

    I would think you would say G

    So are trying to say I should write the code and make the choice of which one or you mean to allow the user to decide which one.

    The way I wrote this code is that if the cell is already filled in then over write what's in the cell.
    Last edited by My Aswer Is This; Apr 11th, 2018 at 09:41 PM.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  4. #24
    Board Regular
    Join Date
    Sep 2015
    Location
    El Paso, TX
    Posts
    87
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Insert checkbox using button

    My apologies, been out and busy

    Yes, the cells (G, H, I) will be empty. I did some tinkering and got it to work, I think. I removed one line of code:

    Code:
    If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
    This is my final result, I moved G:I to I:K

    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    'DOUBLE CLICK CELL TO INSERT DATE AND COLOR
    'Modified 4-11-18 8:35 PM EDT
    Worksheets("Sheet1").Unprotect Password:="1760"
    If Not Intersect(Target, Range("I:K")) Is Nothing Then
    Cancel = True
    Cells(Target.Row, Target.Column).Value = Date
    Cells(Target.Row, Target.Column).Interior.Color = RGB(153, 204, 255)
    Cells(Target.Row, Target.Column).Font.Color = vbBlack
    Cells(Target.Row, Target.Column).Font.Size = 8
    Worksheets("Sheet1").Protect Password:="1760"
    End If
    End Sub
    Let me know if I could have gone a different route.

    I really appreicate all your help

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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