Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How to hide a column once any cell of that col. is not active any

I have a macro, that enables me to unhide a column, should a certain code
being entered in the column before. (there is probably a simpler way for it,
but I am afraid I am pretty new to Visual Basics):

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 And Target.Value = "Locators" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Detectors" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Survey/Navigation Equip." Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Machinery" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Medical Equip. Cap. Assets"
Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Weapons" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Desktops" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Laptops" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Printers" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Scanners" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Digital Cameras" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Radios" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Sat Phones" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Mobile Phones" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Vehicles" Then
Columns("G").Hidden = False

End If
End Sub

What I would like to do now is after the certain code from the column before
has unhidden the column, to be able to make an entry, but when you go to the
next cell in the next column, that the one where the entry was made
automatically gets hidden again. I hope you understand what I mean. Any help
would be very much appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to hide a column once any cell of that col. is not active any

You would use the selectionchange event for this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 6 then exit sub
Columns("G").Hidden = True
End Sub

This would require the user to immediately make the entry after your change
event unhides the column.

--
Regards,
Tom Ogilvy

"Frederic" wrote in message
...
I have a macro, that enables me to unhide a column, should a certain code
being entered in the column before. (there is probably a simpler way for

it,
but I am afraid I am pretty new to Visual Basics):

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 And Target.Value = "Locators" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Detectors" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Survey/Navigation Equip."

Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Machinery" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Medical Equip. Cap.

Assets"
Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Weapons" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Desktops" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Laptops" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Printers" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Scanners" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Digital Cameras" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Radios" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Sat Phones" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Mobile Phones" Then
Columns("G").Hidden = False
ElseIf Target.Column = 5 And Target.Value = "Vehicles" Then
Columns("G").Hidden = False

End If
End Sub

What I would like to do now is after the certain code from the column

before
has unhidden the column, to be able to make an entry, but when you go to

the
next cell in the next column, that the one where the entry was made
automatically gets hidden again. I hope you understand what I mean. Any

help
would be very much appreciated.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get row and column of active cell to highlight? chappi Excel Discussion (Misc queries) 2 August 19th 09 10:21 PM
How to extract just the Column Name of the active cell Fred Excel Discussion (Misc queries) 4 December 8th 05 06:24 PM
How to locate the Row and Column of an Active Cell Fred Excel Discussion (Misc queries) 1 December 7th 05 05:55 PM
Returning Column of active cell Marek Excel Programming 1 April 29th 05 02:13 PM
copying the column of the active cell to another column Paul James[_5_] Excel Programming 2 February 26th 04 08:04 PM


All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"