Setting bkcolor on active cell when left mouse doubleclikked

J

Jan Eikeland

Environment Office97 excel.

Hi, trying to set backgroundcolor of the cell which beeing doublecliked

With Worksheets("Rodeuker").ActiveCell.Interior.Color = RGB(255, 0, 0)

This doesnt work and I cant figure out, cause cant find anything in
help-file for visual basic part of excel.

Thank You
regards jan
 
J

JMay

Did this with Macro Recorder:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End Sub
 
J

Jan Eikeland

thanks , that worked, I must try the macro and watch the code comes out of
it.
reg jan
 
T

Tom Ogilvy

Target provides a reference to the cell being doubleclicked. It would be
better to use that rather than depend on selection:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Target.ColorIndex = 3
' or
' target.Interior.Color = RGB(255, 0, 0)
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

Top