Select or deselect offset entire column double clicking on cell

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,</SPAN></SPAN>

I want a code that can select or deselect offset entire column double clicking on cell.</SPAN></SPAN>
For example if I double click on any cell in the column "L", I want entire column "C" could be selected. If I redo double click then entire column deselected</SPAN></SPAN>
For example if I double click on any cell in the column "N", I want entire column "D" could be selected. If I redo double click then entire column deselected</SPAN></SPAN>

Data looks as shown below</SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQRSTUV
1
2
3
4
5n1n2n3n4n5n6R1R2R3R4R5R6
60111210111-11
7003200000000
8014321-3113-31
9225042-4222-42
10306053-3131-33
11020070-4020-42
12031281-513-1-33
13100490-402-2-22
14211600-313-3-31
15300711-202-2-22
16010923-311-3-11
171201044-220-2-22
182311150-131-1-11
19042001-242-2-22
20153122-153-1-33
21264343064-2-44
22470450-173-1-33
235815620840-22
24092773-195-1-13
25110380401060-24
260114916-11171-13
27113000001060-22
2821412121117-1-11
2931524332128-2-22
3041630443139-3-13
31517405541410-404
3260517651311-3-15
3382620741212-2-26
3490741851113-3-17
35111853041214-2-26
36120074151113-3-17
Sheet1


Thanks In Advance </SPAN></SPAN>
Using version 2000</SPAN></SPAN>

Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 
Last edited:
Glad we could help & thanks for the feedback
Hello Fluff, please could you help me to add one modification that on double clicks code select 2 columns. </SPAN></SPAN>

For example if double click any cell in column "L" code selecting for now entire column "C", does it is possible that code select column "C" and the column "L" as well. It did not come in my mind before Fluff
</SPAN></SPAN>


Kind Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column < 12 Or Target.Column > 22 Then Exit Sub
Dim j As Long
Dim k As Long
j = Target.Column
k = Int((j - 7) / 2) + (j - 7) Mod 2
Union(Columns(k), Columns(Target.Column)).Select
Cancel = True
End Sub
 
Upvote 0
How about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column < 12 Or Target.Column > 22 Then Exit Sub
Dim j As Long
Dim k As Long
j = Target.Column
k = Int((j - 7) / 2) + (j - 7) Mod 2
Union(Columns(k), Columns(Target.Column)).Select
Cancel = True
End Sub
Fluff, so kind of you for prompt modifying of the code as per new request. It is resulting fine! This helps me to a lot because highlighting both I can see which column I am comparing against which column</SPAN></SPAN>

I appreciate a lot your help


Have a nice weekend
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti :grin:
</SPAN></SPAN>
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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