+ Reply to Thread
Results 1 to 7 of 7

how can I make an excel cell "mark" or "unmark" when clicked on?

  1. #1
    Rick
    Guest

    how can I make an excel cell "mark" or "unmark" when clicked on?

    how can I make an excel cell "mark" or "unmark" when clicked on?

  2. #2
    Bob Phillips
    Guest

    Re: how can I make an excel cell "mark" or "unmark" when clicked on?

    One way

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Const WS_RANGE As String = "H1:H10"

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    With Target
    If .Value = "a" Then
    .Value = ""
    Else
    .Value = "a"
    End If
    .Font.Name = "Marlett"
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Rick" <[email protected]> wrote in message
    news:[email protected]...
    > how can I make an excel cell "mark" or "unmark" when clicked on?




  3. #3
    Forum Contributor
    Join Date
    11-27-2005
    Location
    UK
    Posts
    102
    Quote Originally Posted by Rick
    how can I make an excel cell "mark" or "unmark" when clicked on?
    Contained in this worksheet's code module
    It detects a click in columns D or E and then inserts a tick mark. It then moves to column G in the same row. Clicking on a tick, removes it and moves you to column G

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim iOffset As Integer
    On Error GoTo err_handler
    Application.EnableEvents = False
    If Not Application.Intersect(Target, Columns("D:E")) Is Nothing Then
    If Target.Column = 4 Then
    iOffset = 3
    Else
    iOffset = 2
    End If
    If IsEmpty(Target.Value) Then
    With Target
    .Font.Name = "Wingdings"
    .Value = Chr(252)
    End With
    Target.Offset(0, iOffset).Select
    Else
    Target.Value = ""
    Target.Offset(0, iOffset).Select
    End If
    End If
    err_handler:
    Application.EnableEvents = True
    End Sub

  4. #4
    Roger Govier
    Guest

    Re: how can I make an excel cell "mark" or "unmark" when clicked on?

    Hi Rick

    In addition to the method already posted, you could use something like
    the following.

    Private Sub AddCheckBoxes()
    Dim c As Range, myRange As Range
    Set myRange = Selection

    For Each c In myRange.Cells
    ActiveSheet.CheckBoxes.Add(c.Left, c.Top, c.Width,
    c.Height).Select
    With Selection
    .LinkedCell = c.Address
    .Characters.Text = ""
    End With
    With Selection.Font
    .ColorIndex = 2
    End With
    Next
    myRange.Select

    End Sub

    The ColorIndex part is just setting the font to be White, so that you
    don't see the word TRUE when you select the click box.
    The value of the underlying cell will be set to True when clciked, and
    False when unclicked.


    --
    Regards

    Roger Govier


    "Rick" <[email protected]> wrote in message
    news:[email protected]...
    > how can I make an excel cell "mark" or "unmark" when clicked on?




  5. #5
    David
    Guest

    Re: how can I make an excel cell "mark" or "unmark" when clicked on?

    mevetts wrote

    > With Target
    > Font.Name = "Wingdings"
    > Value = Chr(252)
    > End With


    Just a FYI,
    Doesn't happen w/o periods before Font and Value:
    With Target
    ..Font.Name = "Wingdings"
    ..Value = Chr(252)
    End With

    --
    David

  6. #6
    Bob Phillips
    Guest

    Re: how can I make an excel cell "mark" or "unmark" when clicked on?

    I think you might find that is a result of the uploading from ExcelForum to
    the NG, not the poster. Have seen it many times.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "David" <[email protected]> wrote in message
    news:[email protected]...
    > mevetts wrote
    >
    > > With Target
    > > Font.Name = "Wingdings"
    > > Value = Chr(252)
    > > End With

    >
    > Just a FYI,
    > Doesn't happen w/o periods before Font and Value:
    > With Target
    > .Font.Name = "Wingdings"
    > .Value = Chr(252)
    > End With
    >
    > --
    > David




  7. #7
    David
    Guest

    Re: how can I make an excel cell "mark" or "unmark" when clicked on?

    Bob Phillips wrote

    > I think you might find that is a result of the uploading from
    > ExcelForum to the NG, not the poster. Have seen it many times.
    >


    Point taken.

    --
    David

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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