Macro for Hidding a Column??


Posted by Marianne on January 05, 2001 7:14 PM

I have the following code in a Macro that is supposed to hide column C. Instead, it hides Columns A -- I. Can anyone tell me where I went wrong?

Columns("C:C").Select
Range("C2").Activate
Selection.EntireColumn.Hidden = True
Range("A9").Select

'I want to be on A9 after Column C is hidden.

Thanks,

Marianne

Posted by Celia on January 05, 2001 7:22 PM


There's nothing wrong with your code - should work.
Can be shortened though :-
Columns("C:C").Hidden = True
Range("A9").Select

Celia


Posted by Dave on January 05, 2001 10:31 PM

Hi Marianne

As Celia has said, your code should work. All I would add is Unmerge the cells :O) use center across selection instead, much safer.

and again as Celia has said you could shorten your code, maybe even more :O)

Columns(3).Hidden = True
[A9].Select


Dave


OzGrid Business Applications



Posted by Marianne on January 06, 2001 9:28 AM

Re: Macro for Hiding a Column??


I just wanted to let you know that the shorter version worked. I will bet the fact that row 1 was a merged cell was the culprit just like Dave said. Thanks for the input.

Marianne