Highlight some back column cells on double click

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Hi,</SPAN></SPAN>

I need when I double click into any cell in K:L columns highlight cells in the column C</SPAN></SPAN>
When I double click into any cell in P:R columns highlight cells in the column D</SPAN></SPAN>
When I double click into any cell in U:V columns highlight cells in the column E</SPAN></SPAN>

For example when double click on cell K11, highlights the cells C11:C66 (C11 to last cell in the column)</SPAN></SPAN>

For example when double click on cell L17, highlights the cells C17:C66 (C17 to last cell in the column)</SPAN></SPAN>

For example when double click on cell M28, highlights the cells C28:C66 (C28 to last cell in the column)</SPAN></SPAN>

Same conditions will be for the columns P:Q, highlights the column D </SPAN></SPAN>
Same conditions will be for the columns U:V, highlights the column E</SPAN></SPAN>

Example sheet</SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQRSTUVWXY
1
2
3
4
5P1P2P3EM1EM2P1P1P1EM3EM4P2P2P2EM5EM6P3P3P3
6X111
7XX2
8X111
921111
101X1
11X2X1
12X111
131XX
141111
151XX
16X1X
1711X1
181111
19X111
201111
21111
2221X
231111
24X111
251111
26X11
2712X
2811111
291111
301111
3111111
321X11
332211
341X11
352111
361XX
37X111
38X21
39X12
401111
41XXX
422X21
43XX11
44XX1
4511X
4611111
472X11
48121
49X1X
50X11
51X1X
52X111
53X11
5421X11
55XX2
561X2
57X2X
5811X
5911X
6021X1
61X12
622111
631111
641X2
651X1
66XXX
67
68
69
70
71
Sheet15


Thank you in advance</SPAN></SPAN>

Using Excel 2000</SPAN></SPAN>

Regards,</SPAN></SPAN>
Kishan</SPAN></SPAN>
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Paste the following code in the relevant worksheet module of the file and you should be good to go
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Set Target = ActiveCell
    Set DatRng = Range("C5").CurrentRegion
    LastRow = 4 + DatRng.Rows.Count
    Set DatRng = Range("C6", Cells(LastRow, 5))
    DatRng.Interior.Color = xlNone
    Col = Target.Column
    Ro = Target.Row
    
    Select Case Col
     Case 11 To 13
        ColA = 3
     Case 16 To 18
        ColA = 4
     Case 21 To 23
        ColA = 5
     Case Else
        Application.SendKeys ("{Esc}")
        Exit Sub
    End Select
    Set FormatRng = Range(Cells(Ro, ColA), Cells(LastRow, ColA))
    FormatRng.Interior.Color = RGB(255, 255, 0)
    Application.SendKeys ("{Esc}")
End Sub
[code]
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  4/6/2019  8:14:01 AM  EDT
Cancel = True
Dim ans As Long
Dim lastrow As Long
ans = Target.Row
Select Case Target.Column
    Case 11 To 13
        lastrow = Cells(Rows.Count, "C").End(xlUp).Row
    Cells(ans, 3).Resize(lastrow - ans + 1).Interior.ColorIndex = 3
    Case 16 To 18
        lastrow = Cells(Rows.Count, "D").End(xlUp).Row
    Cells(ans, 4).Resize(lastrow - ans + 1).Interior.ColorIndex = 3
    Case 21 To 22
        lastrow = Cells(Rows.Count, "E").End(xlUp).Row
        Cells(ans, 5).Resize(lastrow - ans + 1).Interior.ColorIndex = 3
End Select
End Sub
 
Upvote 0
Hi My Answer Is This
The code needs a line to clear the fill every time the code runs, else after each successful run a new set of cells (some overlapping) will be filled. In time the entire range could have interior.colorindex=3
 
Upvote 0
Paste the following code in the relevant worksheet module of the file and you should be good to go
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Set Target = ActiveCell
Set DatRng = Range("C5").CurrentRegion
LastRow = 4 + DatRng.Rows.Count
Set DatRng = Range("C6", Cells(LastRow, 5))
DatRng.Interior.Color = xlNone
Col = Target.Column
Ro = Target.Row

Select Case Col
Case 11 To 13
ColA = 3
Case 16 To 18
ColA = 4
Case 21 To 23
ColA = 5
Case Else
Application.SendKeys ("{Esc}")
Exit Sub
End Select
Set FormatRng = Range(Cells(Ro, ColA), Cells(LastRow, ColA))
FormatRng.Interior.Color = RGB(255, 255, 0)
Application.SendKeys ("{Esc}")
End Sub
[code][/QUOTE]
[URL="https://www.mrexcel.com/forum/members/ravisingh.html"][COLOR=#0000ff][B]&#x2605 ravisingh[/B][/COLOR][/URL][COLOR=#000000], superb it worked perfect even your idea has been better then mine it highlight the target cells with yellow colour and rest with colour turquoise. [/COLOR]</SPAN></SPAN>[COLOR=#000000]

I do appreciate for your kind help[/COLOR]</SPAN></SPAN>[COLOR=#000000]

Have a nice weekend[/COLOR]</SPAN></SPAN>[COLOR=#000000]

Kind Regards,[/COLOR]</SPAN>[COLOR=#000000]
Kishan :)[/COLOR]</SPAN></SPAN>[COLOR=#000000]
[/COLOR]
 
Upvote 0
Hi Kishan,
I am happy you liked it.
I'm not sure about the turquoise part though...
Regards
Ravi
&#x2605 ravisingh, here is the result of you code after double click see the yellow filled with target cells and rest is filled with colour turquoise (like it is mixed of colour blue and green)</SPAN></SPAN>

Results...</SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQRSTUVWXY
1
2
3
4
5P1P2P3EM1EM2P1P1P1EM3EM4P2P2P2EM5EM6P3P3P3
6X111
7XX2
8X111
921111
101X1
11X2X1
12X111
131XX
141111
151XX
16X1X
1711X1
181111
19X111
201111
21111
2221X
231111
24X111
251111
26X11
2712X
2811111
291111
301111
3111111
321X11
332211
341X11
352111
361XX
37X111
38X21
39X12
401111
41XXX
422X21
43XX11
44XX1
4511X
4611111
472X11
48121
49X1X
50X11
51X1X
52X111
53X11
5421X11
55XX2
561X2
57X2X
5811X
5911X
6021X1
61X12
622111
631111
641X2
651X1
66XXX
67
68
69
70
71
Sheet15


Kind Regards,</SPAN>
Kishan</SPAN></SPAN>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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