ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Column Width (https://www.excelbanter.com/excel-worksheet-functions/253180-column-width.html)

nick

Column Width
 
I would like to hide/unhide columns using the column width (equal to "0"). I
would like to do this as a result of the contents of a cell. For instance,
if user answers "Yes" to a question, then hide column D. Can this be done?

Don Guillett

Column Width
 
You give no detail but this can be done with a worksheet_change event in the
sheet module

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Nick" wrote in message
...
I would like to hide/unhide columns using the column width (equal to "0").
I
would like to do this as a result of the contents of a cell. For
instance,
if user answers "Yes" to a question, then hide column D. Can this be
done?



nick

Column Width
 
For detail.

A1 has a drop down for "Yes" or "No" as choices. I want column C to be
hidden if A1="Yes" and unhidden if A1="No". This would be written as an "if"
function.

=if(A1="Yes", columnwidth C;C=0, columnwidth C;C=10)

This doesnt work this way, is there a command that I can use in the formula
line to control column width?

"Don Guillett" wrote:

You give no detail but this can be done with a worksheet_change event in the
sheet module

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Nick" wrote in message
...
I would like to hide/unhide columns using the column width (equal to "0").
I
would like to do this as a result of the contents of a cell. For
instance,
if user answers "Yes" to a question, then hide column D. Can this be
done?


.


Don Guillett

Column Width
 
Right click sheet tabview codeinsert this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < Range("a1").Address Then Exit Sub
Columns("d").Hidden = False
If LCase(Target) = "yes" Then Columns("d").Hidden = True
'or
'Columns("d").ColumnWidth = 10
'If LCase(Target) = "yes" Then Columns("d").ColumnWidth = 0
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Nick" wrote in message
...
For detail.

A1 has a drop down for "Yes" or "No" as choices. I want column C to be
hidden if A1="Yes" and unhidden if A1="No". This would be written as an
"if"
function.

=if(A1="Yes", columnwidth C;C=0, columnwidth C;C=10)

This doesnt work this way, is there a command that I can use in the
formula
line to control column width?

"Don Guillett" wrote:

You give no detail but this can be done with a worksheet_change event in
the
sheet module

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Nick" wrote in message
...
I would like to hide/unhide columns using the column width (equal to
"0").
I
would like to do this as a result of the contents of a cell. For
instance,
if user answers "Yes" to a question, then hide column D. Can this be
done?


.




All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com