Beforedoubleclick VBA Code not completing process

Rob1972

New Member
Joined
May 19, 2018
Messages
9
I have a vba code which works well up to a point, the code i'm using is as follows

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("$L$3:$L$187")) Is Nothing Then Exit Sub
Select Case Target
Case ""
Target = "CHECKED"
Target.Interior.ColorIndex = 4
Case Else
Target = "NOT CHECKED"
Target.Interior.ColorIndex = 3
End Select
Cancel = True
End Sub

the code works until i doubleclick a cell in error, for example

if i doubleclick cell L5 it will insert the phrase "CHECKED" and turn green as requested, if however I have clicked on it in error and i then doubleclick it again it will enter the phrase "NOT CHECKED" and turn red as requested, however when I have completed the necessary checks and the return to the cell L5 and doubleclick on it it will do nothing and won't enter the "checked" phrase.

can anyone suggets a solution

Many thanks

Rob
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You haven't told it to do that.

After your first Case "" add:

Code:
, "NOT CHECKED"
 
Upvote 0
Your script says to only enter [TABLE="width: 95"]
<colgroup><col></colgroup><tbody>[TR]
[TD]CHECKED[/TD]
[/TR]
</tbody>[/TABLE]
If the cell is empty.

You will need to clear the cell and then double click on it.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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