Hidding columns

P

pcor

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top