Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Hiding complete Rows using a procedure

I want to hide rows 5,6 and 7 in a worksheet, I recorded the following macro
but it hides all rows containing data from 5 downwards.

Sub HideSetupRows()
Rows("5:7").Select
Range("B5").Activate
Selection.EntireRow.Hidden = True
Range("B8").Select
End Sub

I have no idea why this happens, could any one offer an expaination?

Thanks in advance

Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Hiding complete Rows using a procedure

I would suspect you have some other code running to cause this. The code
you've posted works fine for me.


"Mark Dullingham" wrote in
message ...
I want to hide rows 5,6 and 7 in a worksheet, I recorded the following
macro
but it hides all rows containing data from 5 downwards.

Sub HideSetupRows()
Rows("5:7").Select
Range("B5").Activate
Selection.EntireRow.Hidden = True
Range("B8").Select
End Sub

I have no idea why this happens, could any one offer an expaination?

Thanks in advance

Mark



  #4   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Hiding complete Rows using a procedure

Mark -

Your procedure looks fine and works properly when I test it, although it
does have some unnecessary statements (see alternative below). Consider the
fact that all of your statements operate on the activesheet (whatever sheet
you see when you invoke the macro). Are you viewing a different sheet after
running the macro ? This would give the illusion of failure.

Try running the macro while viewing the worksheet instead of from the VB
Editor. Press Alt+F8, select your macro, and choose Run. Let us know what
happens.

Alternative:
Sub HideSetupRows()
Rows("5:7").Hidden = True
End Sub
--
Jay


"Mark Dullingham" wrote:

I want to hide rows 5,6 and 7 in a worksheet, I recorded the following macro
but it hides all rows containing data from 5 downwards.

Sub HideSetupRows()
Rows("5:7").Select
Range("B5").Activate
Selection.EntireRow.Hidden = True
Range("B8").Select
End Sub

I have no idea why this happens, could any one offer an expaination?

Thanks in advance

Mark

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Hiding complete Rows using a procedure

This is a bit wierd

I was calling this sub from an option button on a multipage user form, to
see what was happening I changed the code to

Rows ("5:7").Select

and placed it in the OptionButton_Click sub directly instead of caling it
and for some bizarre reason rows 2:59 are being selected

I do have a couple of ontime procedures running and the active sheet has a
Worksheet_change routine but i can't see how they would matter

"Jay" wrote:

Mark -

Your procedure looks fine and works properly when I test it, although it
does have some unnecessary statements (see alternative below). Consider the
fact that all of your statements operate on the activesheet (whatever sheet
you see when you invoke the macro). Are you viewing a different sheet after
running the macro ? This would give the illusion of failure.

Try running the macro while viewing the worksheet instead of from the VB
Editor. Press Alt+F8, select your macro, and choose Run. Let us know what
happens.

Alternative:
Sub HideSetupRows()
Rows("5:7").Hidden = True
End Sub
--
Jay


"Mark Dullingham" wrote:

I want to hide rows 5,6 and 7 in a worksheet, I recorded the following macro
but it hides all rows containing data from 5 downwards.

Sub HideSetupRows()
Rows("5:7").Select
Range("B5").Activate
Selection.EntireRow.Hidden = True
Range("B8").Select
End Sub

I have no idea why this happens, could any one offer an expaination?

Thanks in advance

Mark



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Hiding complete Rows using a procedure

I've moved the row statements into 2 subs in a standard module and called
them from the option buttons in thee user form and all is ok now.

Thanks for your help guys

Mark

"Mark Dullingham" wrote:

This is a bit wierd

I was calling this sub from an option button on a multipage user form, to
see what was happening I changed the code to

Rows ("5:7").Select

and placed it in the OptionButton_Click sub directly instead of caling it
and for some bizarre reason rows 2:59 are being selected

I do have a couple of ontime procedures running and the active sheet has a
Worksheet_change routine but i can't see how they would matter

"Jay" wrote:

Mark -

Your procedure looks fine and works properly when I test it, although it
does have some unnecessary statements (see alternative below). Consider the
fact that all of your statements operate on the activesheet (whatever sheet
you see when you invoke the macro). Are you viewing a different sheet after
running the macro ? This would give the illusion of failure.

Try running the macro while viewing the worksheet instead of from the VB
Editor. Press Alt+F8, select your macro, and choose Run. Let us know what
happens.

Alternative:
Sub HideSetupRows()
Rows("5:7").Hidden = True
End Sub
--
Jay


"Mark Dullingham" wrote:

I want to hide rows 5,6 and 7 in a worksheet, I recorded the following macro
but it hides all rows containing data from 5 downwards.

Sub HideSetupRows()
Rows("5:7").Select
Range("B5").Activate
Selection.EntireRow.Hidden = True
Range("B8").Select
End Sub

I have no idea why this happens, could any one offer an expaination?

Thanks in advance

Mark

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding rows and columns in a procedure Doo0592 Excel Programming 3 September 5th 06 04:29 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
End Sub, End complete procedure BEEJAY Excel Programming 5 June 23rd 06 04:09 PM
Copying Row Heights, or Complete Rows Sam Fowler Excel Programming 0 September 16th 05 01:29 AM
How do I sort by complete rows in excell Snoopy Excel Worksheet Functions 2 April 1st 05 01:41 PM


All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"