Tick macro

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I have the macro below which I use to treat my own tick boxes in cells "a" = tick

It works great except you have to click away before it will change again.
I was woundering if there was a bettter way i could do this?

Basickly I want a macro that gives me an "a" in the cell i click on if its empty and "" if it has an "a"

Heres my code:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Selected Target
 
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Selected Target
End Sub
Private Sub Selected(ByVal Target As Range)
  
If Not Intersect(Target, Range("AL52:AL300")) Is Nothing _
        And Target.Count = 1 Then
        If Target.Value = "" Then
        Target = "a"
        Else
        Target = ""
End If
End If
  
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Re: Help with a problem with this tick macro

Does this work any better?
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    If Not Intersect(Target, Range("AL52:AL300")) Is Nothing _
        And Target.Count = 1 Then
        Cancel = True
        If Target.Value = "" Then
            Target = "a"
        Else
            Target = ""
        End If
    End If

End Sub
 
Upvote 0
Re: Help with a problem with this tick macro

twh, If you get fed up with double clicking annoying you then, perhaps this could annoy you instead....
Code:
[COLOR=inherit]

[/COLOR]Private Sub Selected(ByVal Target As Range)  
If Not Intersect(Target, Range("AL52:AL300")) Is Nothing _
        And Target.Count = 1 Then
        If Target.Value = "" Then
        Target = "a"
        Else
        Target = ""
End If


Application.EnableEvents = False
Target.Offset(0, 1).Select
Application.EnableEvents = True
End If
End Sub

If column AM is empty and you can hide it then you will just get a black line to the right of the cell just edited.

;)
 
Last edited:
Upvote 0
Re: Help with a problem with this tick macro

I think its ahuge improvement thank you Snakehips :-)
 
Upvote 0
Thanks to Snakehips great idea I realsed, I have the first ten rows hidden anyway so i just change "offset" for Range("AL5").select
its perfect! thank very much would never of thought of this I a million years :-)
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top