ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hidding columns (https://www.excelbanter.com/excel-programming/272385-hidding-columns.html)

pcor[_2_]

Hidding columns
 
First I have to say SORRY
I posted this request a while back. Got a very good answer, applied it and
it worked very well
Then I accidently erase the entire macro
Pleas help again
Many thanks


I sure could use some help with this problem
I want to build a macro that will hide and an other macro that will unhide
columns.
I want the macro to hide columns starting with the col where the cursor is
located all the way back to and include column B
Then I would require a macro to unhide the same columns.
I would appreciate any help I can get




Tom Ogilvy

Hidding columns
 
From Ramesh

Dear pcor,

The foll code will do ur req,

Sub Myhide()
With Excel.Application
.Sheets("Sheet4").Select
.Cells(1, .ActiveCell.Column).Select
.Range(.ActiveCell, .Range("B1")).Select
.Selection.EntireColumn.Hidden = True
End With
End Sub

Sub MyUnhide()
With Excel.Application
.Sheets("Sheet4").Select
.Selection.EntireColumn.Hidden = False
.Range("A1").Select
End With
End Sub

Regards,
Ramesh
------------------
From Orlando Magalhaes Filho
Hi,

See this:

Sub HideColumns()
Range(Cells(1, ActiveCell.Column), Cells(1, 256)).EntireColumn.Hidden =
True
Range("B1").EntireColumn.Hidden = True
End Sub

Sub UnHideColumns()
Range(Cells(1, ActiveCell.Column), Cells(1, 256)).EntireColumn.Hidden =
False
Range("B1").EntireColumn.Hidden = False
End Sub


HTH

---
Orlando Magalhães Filho
------------------------

From Brian B

No need for 2 macros. This one will do the job :-

'------------------------------------------------------
Sub HIDE_UNHIDE()
Dim SetStatus As Boolean
'- check if column B hidden
If ActiveSheet.Columns(2).Hidden = True Then
ActiveSheet.Columns.EntireColumn.Hidden = False
Else
For c = 2 To ActiveCell.Column
ActiveSheet.Columns(c).EntireColumn.Hidden = True
Next
End If
End Sub
'------------------------------------------------------

Regards
BrianB

--
Regards,
Tom Ogilvy



pcor wrote in message
le.rogers.com...
First I have to say SORRY
I posted this request a while back. Got a very good answer, applied it and
it worked very well
Then I accidently erase the entire macro
Pleas help again
Many thanks


I sure could use some help with this problem
I want to build a macro that will hide and an other macro that will

unhide
columns.
I want the macro to hide columns starting with the col where the cursor is
located all the way back to and include column B
Then I would require a macro to unhide the same columns.
I would appreciate any help I can get







All times are GMT +1. The time now is 05:22 PM.

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