mouse click or mouseover and get color

  • Thread starter Thread starter sakijung
  • Start date Start date
S

sakijung

Good evening. Please help me to edit this macro code.
Sub Macro1()
With Selection.Interior
ColorIndex = 6
Pattern = xlSolid
End With
Range("G1").Select
With Selection.Interior
ColorIndex = 6
Pattern = xlSolid
End With
End Sub
The problem is I would like to click mouse to highlight the cell. And
I want this code to do some picture on stand cheer with my students in
sport day. I don't want to click the color plate and click on cell. I
just want one click. For example I select the yellow and then I click
mouse on any cell to make heart shaped such as j1 k1 j2 k2,......
Thank you.
 
There is no SingleClick event for a worksheet.
There is an event called SelectionChange, but for your request I believe you
would find this more troublesome than it's worth.

How about DoubleClick?

Here's how:
Right-click the sheet tab, select View Code.

Paste this code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
With Target.Interior
.ColorIndex = IIf(.ColorIndex <> 6, 6, xlColorIndexNone)
End With
Cancel = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top