Hi,
how can i hide/unhide columns by clicking on another one ? For example when i click on a1, b1 with its content appears, another click, it dissapears. Normaly only a1 a3 are shown.
Something like dropdown menu.
thank you
Hi,
how can i hide/unhide columns by clicking on another one ? For example when i click on a1, b1 with its content appears, another click, it dissapears. Normaly only a1 a3 are shown.
Something like dropdown menu.
thank you
Try pasting this code into the relevant pane (e.g. Sheet1) in the VBA editor (Alt F11).
![]()
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Column = 1 Then If Columns(2).Hidden = True Then Columns(2).Hidden = False Else Columns(2).Hidden = True End If End If End Sub
Have you looked at Grouping?
http://datanalaysistips.blogspot.com...group-and.html
THx for answers, both would work, but i have another problem. The thing i wanted to have in those hiding/unhiding rows are pictures, and i don't know how to do this, pic is allways just floating on top, either the cells are hiden, resized or whatever.
Any thoughts about this? The think i need is click - picture vissible between a1 and a2(or a3) click-hidden. I need to have "picture link" in every row and i want to dispplay them on click or double click as many as i want - so placing picture in comment wont work, cause only 1 will be vissible at a time.
How about....
![]()
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Column = 1 Then If Columns(2).Hidden = True Then Columns(2).Hidden = False For N = 1 To ActiveSheet.DrawingObjects.Count If ActiveSheet.DrawingObjects(N).TopLeftCell.Column = 2 Then ActiveSheet.DrawingObjects(N).Visible = True End If Next N Else Columns(2).Hidden = True For N = 1 To ActiveSheet.DrawingObjects.Count If ActiveSheet.DrawingObjects(N).TopLeftCell.Column = 2 Then ActiveSheet.DrawingObjects(N).Visible = False End If Next N End If End If End Sub
Go to the properties of the image and select the "Move and Size With Cells" option. This will hide the image when the row/column is hidden.
Thank you mrice, working like charm. Now i need to add a slight modification to the formula, how can i modify it to get this result: every second row will be hiding when clicking on the row top of it. ( there will be hidden picture in hide/unhide rows - 2,4,6,8,10... by clicking on 1,3,5,7,9...
Try this variation.
![]()
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Columns.Count = 1 And WorksheetFunction.IsOdd(Target.Column) = True Then If Columns(Target.Column + 1).Hidden = True Then Columns(Target.Column + 1).Hidden = False For N = 1 To ActiveSheet.DrawingObjects.Count If ActiveSheet.DrawingObjects(N).TopLeftCell.Column = Target.Column + 1 Then ActiveSheet.DrawingObjects(N).Visible = True End If Next N Else Columns(Target.Column + 1).Hidden = True For N = 1 To ActiveSheet.DrawingObjects.Count If ActiveSheet.DrawingObjects(N).TopLeftCell.Column = Target.Column + 1 Then ActiveSheet.DrawingObjects(N).Visible = False End If Next N End If End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks