ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding columns based upon a value (or vice versa) (https://www.excelbanter.com/excel-programming/373996-hiding-columns-based-upon-value-vice-versa.html)

Matthew Balch[_2_]

Hiding columns based upon a value (or vice versa)
 
How do I do VB to read a row then act on the relevant columns.

Say in row 6 I have 3 different variants, A B & C. If user pushes button A I
only want all the columns with A in row 3 displayed.

How do I do this?

Charles Chickering

Hiding columns based upon a value (or vice versa)
 
Private Sub ButtonA_Click()
Dim cnt as long
Dim lCol as Long 'Last Column
Rows(3).EntireColumn.Hidden = False
lCol = Cells(3,Columns.Count).End(xlToLeft).Column
For cnt = 1 to lCol
If Cells(3, cnt) < "A" Then Columns(cnt).Hidden = True
Next
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


"Matthew Balch" wrote:

How do I do VB to read a row then act on the relevant columns.

Say in row 6 I have 3 different variants, A B & C. If user pushes button A I
only want all the columns with A in row 3 displayed.

How do I do this?



All times are GMT +1. The time now is 03:55 PM.

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