+ Reply to Thread
Results 1 to 8 of 8

right clicking to make check marks

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161

    right clicking to make check marks

    The code below was offered earlier by moderator, Davesexcel. I am hopeful that someone can expand on this code to apply this technique to two or more non-contiguous ranges. Instead of just working for range A1:A10, I'd like to see how the check marks can be inserted in range A1:A10 and in range C1:C10.



    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
        If Union(Range("$A1:$A10"), Target).Address = Range("$A1:$A10").Address Then
            Cancel = True
            If Target <> "a" Then
                With Target.Font
                    .Name = "Webdings"
                    .Size = 10
                End With
                Target.FormulaR1C1 = "a"
        Else: With Target.Font
                .Name = "Webdings"
                .Size = 10
            End With
            Target.ClearContents
        End If
    
    End If
    Thanks in advance

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Conor,

    Provided the data in "C" is the same as "A" then a simple change will do it.
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
        If Not Target Intersect(Range("A1:A10"), Range("C1:C10")) Is Nothing Then
            Cancel = True
            If Target <> "a" Then
                With Target.Font
                    .Name = "Webdings"
                    .Size = 10
                End With
                Target.FormulaR1C1 = "a"
        Else: With Target.Font
                .Name = "Webdings"
                .Size = 10
            End With
            Target.ClearContents
        End If
    
    End If
    Sincerely,,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161

    Didn't work

    Leith,

    Thank you, but that did not work. I get a generic "syntax error" when I substitute your line for the original. But I realize my original post was not terribly informative. The original post earlier today was titled "radio buttons" in case you want to refer to it. But the way the original code works, there is no data in A1:A10 and if I expand it, C1:C10 would also be empty. I want to use the check marks to sum, count, etc. the adjacent cells in columns B, D, etc with a sumif, countif, etc.

    Thanks again.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Conor,

    In that case, it would be better if you continue this discussion with Dave, since he is already familiar with what you want to do and the previous post.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161

    thanks anyway.

    I appreciate your time and effort.

    Conor

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("A1:A10,C1:C10")) Is Nothing Then
            Cancel = True
            If Target <> "a" Then
                With Target.Font
                    .Name = "Webdings"
                    .Size = 10
                End With
                Target.FormulaR1C1 = "a"
        Else: With Target.Font
                .Name = "Webdings"
                .Size = 10
            End With
            Target.ClearContents
        End If
    End If
    End Sub
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  7. #7
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161
    Shazam!! Thanks. That is exactly what I wanted.

    Conor

  8. #8
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Your welcome

    VBA Noob

+ 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