Hi Experts,
I want to hide and unhide column AI by double clicking on a certain cell, let's say S25. Can this be done?
Greetings, Bengtar
Hi Experts,
I want to hide and unhide column AI by double clicking on a certain cell, let's say S25. Can this be done?
Greetings, Bengtar
Last edited by bta; 02-01-2009 at 10:40 AM.
bta, yes you can use the Before DoubleClick event on the sheet in question.
In native XL right click on the tab you wish the code to fire against, select View Code and insert the below into the resulting window:
![]()
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address = "$S$25" Then: Columns(35).Hidden = (Columns(35).Hidden = False): Cancel = True End Sub
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Try this
![]()
Option Explicit Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address <> "$S$25" Then Exit Sub Columns(35).EntireColumn.Hidden = Not Columns(35).Hidden End Sub
Last edited by royUK; 02-01-2009 at 07:48 AM.
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Another slight differentr version
'These instructions pre typed & are worded to cater for the novice programmer
'To install macro to correct location
'Copy this macro
'GoTo Excel
'Select sheet this is to appy to
'Right Click on Sheet Name Tab > select View Code
'Past macro into the Worksheet Module displayed
![]()
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not Application.Intersect(Target, Range("s25")) Is Nothing Then Columns(35).EntireColumn.Hidden = Not Columns(35).EntireColumn.Hidden End If End Sub
Please Read Forum Rules Before Posting
Wrap VBA code by selecting the code and clicking the # icon or Read This
How To Cross Post politely
Top Excel links for beginners to Experts
If you are pleased with a member's answer then use the Scales icon to rate it
If my reply has assistedor failed to assist you
I welcome your Feedback.
Note, as per my example, if the double click action on S25 is purely to toggle column visibility be sure to use Cancel = True on the event itself
(else you will be in Edit Mode on the Target).
DonkeyOte
thanks for pointing that out I forgot about that little trap
Could this also be possible with a single click?
There is no single click event, you could use the BeforeRightClck event
Thank you all!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks