View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
sgl sgl is offline
external usenet poster
 
Posts: 80
Default Problem define range for multiple sheets

Hi all,

I am trying to develop a routine for hiding rows that can be used on all
sheets. In Sheet 1, which is the Master sheet, I count the number of rows
that I can hide. The code when applied to Sheet 1 works.

When I try to apply it to sheet 2 it fails. It fails because the "
lRowsCount " counts the ActiveSheet selected rows. Can someone help to get
the range defined correctly so that it can be applied to all sheets.

'Count number of rows to hide from Sheet 1
Set rngRows = wksWS1.Range("ptrMinMaxWageScale", _
Range("ptrMinMaxWageScale").End(xlUp).Offset(1, 0)).Select

'Count number of rows to hide from Sheet 1 - Code fails on Sheet 2 as it is
counting the ActiveSheet Selection which in this example is Sheet 2
lRowsCount = Selection.Rows.Count - 1

' Apply number of Rows to hide in Sheet 2
ActiveSheet.Range("ptrMinMaxWageScale", _
Range("ptrMinMaxWageScale").Offset(-lRowsCount, 0)).Select

Selection.EntireRow.Hidden = True

Many thanks in advance/sgl