Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default "With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets

Hi all,

I have a macro assigned to a "Hide Unused Rows Throughout Workbook"
button that is located on the last worksheet in a workbook. I am
writing individual subs to hide specific rows on each worksheet in the
workbook. Below is a sample of one of those subs.

I'm trying to write this as efficiently as possible. I previously had
this set up using a sheets("sheetname").activate at the beginning of
each subroutine. This worked fine, but even with the
Application.Screenupdating set to False, the users could see the macro
cycling through all of the various worksheets in the workbook as it hid
the particular rows called for by the specific macro for each
worksheet. Plus, it seemed to take longer than I would have liked.

I thought I'd try the "With" function for each worksheet's "hide"
macro, but that doesn't seem to work well if it's being called from
another worksheet. Any thoughts?


Sub HideUnusedRowsDiag()

Application.ScreenUpdating = False
With Sheets("Diag")
If (Left(Cells(34, 1).Text, 12)) = "(Enter notes" Then
Rows("34").EntireRow.Hidden = True
Else
Rows("34").EntireRow.Hidden = False
End If
End With
Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets

Put a period in front of rows so it is qualified by the With Object

Sub HideUnusedRowsDiag()

Application.ScreenUpdating = False
With Sheets("Diag")
If (Left(Cells(34, 1).Text, 12)) = "(Enter notes" Then
.Rows("34").EntireRow.Hidden = True
Else
.Rows("34").EntireRow.Hidden = False
End If
End With
Application.ScreenUpdating = True
End Sub

--
Regards,
Tom Ogilvy


"Punsterr" wrote in message
oups.com...
Hi all,

I have a macro assigned to a "Hide Unused Rows Throughout Workbook"
button that is located on the last worksheet in a workbook. I am
writing individual subs to hide specific rows on each worksheet in the
workbook. Below is a sample of one of those subs.

I'm trying to write this as efficiently as possible. I previously had
this set up using a sheets("sheetname").activate at the beginning of
each subroutine. This worked fine, but even with the
Application.Screenupdating set to False, the users could see the macro
cycling through all of the various worksheets in the workbook as it hid
the particular rows called for by the specific macro for each
worksheet. Plus, it seemed to take longer than I would have liked.

I thought I'd try the "With" function for each worksheet's "hide"
macro, but that doesn't seem to work well if it's being called from
another worksheet. Any thoughts?


Sub HideUnusedRowsDiag()

Application.ScreenUpdating = False
With Sheets("Diag")
If (Left(Cells(34, 1).Text, 12)) = "(Enter notes" Then
Rows("34").EntireRow.Hidden = True
Else
Rows("34").EntireRow.Hidden = False
End If
End With
Application.ScreenUpdating = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default "With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets

Punsterr,
I think you'll find it the omission of "." before the Cells and Row.
Without that qualification, they refer to the sheet that is running the
code, whereas with it they obviously refer back to the object stated in the
With.

NickHK

"Punsterr" wrote in message
oups.com...
Hi all,

I have a macro assigned to a "Hide Unused Rows Throughout Workbook"
button that is located on the last worksheet in a workbook. I am
writing individual subs to hide specific rows on each worksheet in the
workbook. Below is a sample of one of those subs.

I'm trying to write this as efficiently as possible. I previously had
this set up using a sheets("sheetname").activate at the beginning of
each subroutine. This worked fine, but even with the
Application.Screenupdating set to False, the users could see the macro
cycling through all of the various worksheets in the workbook as it hid
the particular rows called for by the specific macro for each
worksheet. Plus, it seemed to take longer than I would have liked.

I thought I'd try the "With" function for each worksheet's "hide"
macro, but that doesn't seem to work well if it's being called from
another worksheet. Any thoughts?


Sub HideUnusedRowsDiag()

Application.ScreenUpdating = False
With Sheets("Diag")
If (Left(Cells(34, 1).Text, 12)) = "(Enter notes" Then
Rows("34").EntireRow.Hidden = True
Else
Rows("34").EntireRow.Hidden = False
End If
End With
Application.ScreenUpdating = True
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default "With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets

Tom and Nick,

Thanks so much for your quick responses (and for educating me). That
fixed the problem.

Rick

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
Protecting/Unprotecting all sheets with macro leads to "image" iss MikeR Excel Worksheet Functions 3 February 22nd 10 09:33 PM
Printing Selected worksheets but exclude the sheet "Sheets" Dolphinv4 Excel Discussion (Misc queries) 1 January 3rd 08 12:13 PM
Sheets("Rpt").Copy different results from running in macro than off excel menu?? tmbo Excel Discussion (Misc queries) 7 August 9th 06 01:13 PM
Auto "copy and paste" individual cells from various sheets into one sheet ?? [email protected] Excel Discussion (Misc queries) 2 March 1st 06 03:19 AM
Creating an "update" button and using a macro to copy data from multiple sheets SPIRITTTJ Excel Programming 1 January 8th 04 05:50 PM


All times are GMT +1. The time now is 10:53 AM.

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

About Us

"It's about Microsoft Excel"