|
Prev: VBA VLookup
Next: ChangeLink Command Not Working
From: Andy the yeti on 19 Jan 2006 10:52 Is there a piece of VBA code that will allow me to run a macro at a push of a button that will hide or unhide columns in a workbook dependant on a given criteria in say row A ? For example if columns A, B, C & F, & H has a ?1? in then leave and if columns D, E, & G has a ?2? then ?hide? ? Many thanks Andy
From: RC- on 19 Jan 2006 13:26 Sub HideColumns() Range("A1").Select Do Until ActiveCell.Value = "" If ActiveCell.Value = 2 Then Selection.EntireColumn.Hidden = True End If ActiveCell.Offset(ColumnOffset:=1).Activate Loop Range("A1").Select End Sub HTH RC- "Andy the yeti" <Andytheyeti(a)discussions.microsoft.com> wrote in message news:4E025724-6AF2-4C0B-BD8C-52FD5C69F046(a)microsoft.com... > Is there a piece of VBA code that will allow me to run a macro at a push > of a > button that will hide or unhide columns in a workbook dependant on a given > criteria in say row A ? > For example if columns A, B, C & F, & H has a "1" in then leave and if > columns D, E, & G has a "2" then 'hide' ? > > Many thanks > > Andy >
From: N10 on 19 Jan 2006 21:11 Hi This might be a little faster for you Sub Hidetwo() Application.ScreenUpdating = False Dim task As Range Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Set task = Selection For Each cell In task If cell.Value = "2" Then cell.EntireColumn.Hidden = True Next Application.ScreenUpdating = True End Sub "RC-" <r_candee(a)hotmail.com> wrote in message news:eIsz9WSHGHA.1728(a)TK2MSFTNGP09.phx.gbl... > Sub HideColumns() > > Range("A1").Select > Do Until ActiveCell.Value = "" > If ActiveCell.Value = 2 Then > Selection.EntireColumn.Hidden = True > End If > > ActiveCell.Offset(ColumnOffset:=1).Activate > Loop > > Range("A1").Select > > End Sub > > HTH > RC- > > "Andy the yeti" <Andytheyeti(a)discussions.microsoft.com> wrote in message > news:4E025724-6AF2-4C0B-BD8C-52FD5C69F046(a)microsoft.com... >> Is there a piece of VBA code that will allow me to run a macro at a push >> of a >> button that will hide or unhide columns in a workbook dependant on a >> given >> criteria in say row A ? >> For example if columns A, B, C & F, & H has a "1" in then leave and if >> columns D, E, & G has a "2" then 'hide' ? >> >> Many thanks >> >> Andy >> > >
From: Andy the yeti on 20 Jan 2006 03:30 thank you both !! "N10" wrote: > Hi > This might be a little faster for you > > Sub Hidetwo() > > > Application.ScreenUpdating = False > > Dim task As Range > Range("A1").Select > Range(Selection, Selection.End(xlToRight)).Select > Set task = Selection > For Each cell In task > If cell.Value = "2" Then cell.EntireColumn.Hidden = True > Next > Application.ScreenUpdating = True > > > End Sub > > "RC-" <r_candee(a)hotmail.com> wrote in message > news:eIsz9WSHGHA.1728(a)TK2MSFTNGP09.phx.gbl... > > Sub HideColumns() > > > > Range("A1").Select > > Do Until ActiveCell.Value = "" > > If ActiveCell.Value = 2 Then > > Selection.EntireColumn.Hidden = True > > End If > > > > ActiveCell.Offset(ColumnOffset:=1).Activate > > Loop > > > > Range("A1").Select > > > > End Sub > > > > HTH > > RC- > > > > "Andy the yeti" <Andytheyeti(a)discussions.microsoft.com> wrote in message > > news:4E025724-6AF2-4C0B-BD8C-52FD5C69F046(a)microsoft.com... > >> Is there a piece of VBA code that will allow me to run a macro at a push > >> of a > >> button that will hide or unhide columns in a workbook dependant on a > >> given > >> criteria in say row A ? > >> For example if columns A, B, C & F, & H has a "1" in then leave and if > >> columns D, E, & G has a "2" then 'hide' ? > >> > >> Many thanks > >> > >> Andy > >> > > > > > > >
|
Pages: 1 Prev: VBA VLookup Next: ChangeLink Command Not Working |