Double Click to activate a macro

DrDebit

Board Regular
Joined
May 20, 2013
Messages
72
Is it possible to have several different formulas of conditional formatting in a cell, but they will not occur until the cell is double-clicked?

Thank you!
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,421
Sure a Vba script can be activate using a Double Click.
But we do not need to use Conditional formatting.

So when you double click on A1 for example what do you want to happen.

Tell me where you want to double click and when you do so what do you want to happen.
Here is a example of a Double Click Script.

If you double click on any cell in column A if the value in the cell is 2 the cell color will be Blue

If you double click on any cell in column A if the value in the cell is 5 the cells color will be Red

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  8/16/2019  3:07:17 AM  EDT
If Target.Column = 1 And Target.Value <> "" Then
    Cancel = True
        With Target.Interior
        
            Select Case Target.Value
                Case 2
                    .ColorIndex = 5
                Case 5
                    .ColorIndex = 3
            End Select
        End With
End If
End Sub
 

DrDebit

Board Regular
Joined
May 20, 2013
Messages
72
Thank you so much for trying to help me.
I pasted your macro in a blank worksheet, but it didn't work...not sure what I am doing wrong...

I have written 4 macros, to change the color of the fill for a cell based on the user's needs (it is part of a game). However, I thought it would be easier to have the user double click and depending on the cell address with a vlookup, will change the cell to the right color.

Again, thank you for trying to help.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,421
Did you double click on a 5 in column A

Or Double click on a 2 in column A

??

That is what my script requires as per my original post.

This is a example since you never said what you want to double click on and never said what you wanted to happen.


To get specific help you have to provide specific details.
 

DrDebit

Board Regular
Joined
May 20, 2013
Messages
72
When I double click in one of the cells, I go to edit mode, but nothing else happens.

Thank you so much.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,421
A asked you this:
Did you double click on a 5 in column A

Or Double click on a 2 in column A

And you did not answer me.

This might not do what you wanted but your original post was very vague about what you wanted.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,421
I also asked this question:
So when you double click on A1 for example what do you want to happen.

Tell me where you want to double click and when you do so what do you want to happen.

If your not willing to answer these questions I'm not able to help you.
 

Forum statistics

Threads
1,085,436
Messages
5,383,657
Members
401,845
Latest member
ZmutLarr

Some videos you may like

This Week's Hot Topics

Top