+ Reply to Thread
Results 1 to 4 of 4

Macro used to insert and remove a tick

  1. #1
    Registered User
    Join Date
    03-05-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    10

    Macro used to insert and remove a tick

    I have the following macro:

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True

    With Target
    If Not Intersect(.Cells, Me.Range("m6:m400")) Is Nothing Then
    If LCase(.Value) = "P" Then
    .ClearContents
    Else
    .Value = "P"

    End If

    This allows me to insert a tick with the right mouse button in column M when the font style in column M is wingdings 2. However I am unable to remove the tick with a second click of the right mouse button. Can anyone help? Also can the macro allocate the font style for that row rather than changing it manually?

  2. #2
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Macro used to insert and remove a tick

    Hi Hobsons

    I am not familiar with BeforeRightClick, but you seem to be testing for lower case "P" whereas Winding 2 upper case "P" is a tick.

    So perhaps the line does not need the LCase and therefore should read "If .Value = "P" then" ?

    Let me know if this works.

    Regards
    Alastair

  3. #3
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Macro used to insert and remove a tick

    Option:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("M6:M400")) Is Nothing Then
    Target = IIf(Target = "P", "", "P")
    Target.Offset(, 1).Select
    End If
    End Sub

  4. #4
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Macro used to insert and remove a tick

    Option:
    HTML Code: 

+ 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