Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hide Worksheet

Hello,

I have created a workbook with 21 worksheets. Quite often, some of the
worksheets will not be required. Is it possible to create a macro that will
look for a value in a specific cell on a worksheet (e.g. M7) and if that
cell is blank, hide the worksheet?

Grateful for any assistance.

Paul.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Hide Worksheet

Hi Paul

Sub test()
With Sheets(3)
If .Range("M7").Value = "" Then
.Visible = False
Else
.Visible = True
End If
End With
End Sub

Now you figure out how to write into M7 when the sheet is hidden ;-)


HTH. Best wishes Harald

"Skip" skrev i melding
...
Hello,

I have created a workbook with 21 worksheets. Quite often, some of the
worksheets will not be required. Is it possible to create a macro that

will
look for a value in a specific cell on a worksheet (e.g. M7) and if that
cell is blank, hide the worksheet?

Grateful for any assistance.

Paul.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Hide Worksheet

Hi Paul

try this

Sub hideworksheetswithblank()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Range("m7") = "" Then
ws.Visible = xlSheetHidden
Else
ws.Visible = xlSheetVisible
End If
Next

Bear in mind that you must have at least one sheet visible
in excel, so if you try and hide them all, an error will
occur.


-----Original Message-----
Hi Paul

Sub test()
With Sheets(3)
If .Range("M7").Value = "" Then
.Visible = False
Else
.Visible = True
End If
End With
End Sub

Now you figure out how to write into M7 when the sheet is

hidden ;-)


HTH. Best wishes Harald

"Skip" skrev i melding
...
Hello,

I have created a workbook with 21 worksheets. Quite

often, some of the
worksheets will not be required. Is it possible to

create a macro that
will
look for a value in a specific cell on a worksheet

(e.g. M7) and if that
cell is blank, hide the worksheet?

Grateful for any assistance.

Paul.




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Hide Worksheet

Thanks guys. I had to take out the 'End If' line because it gave a compile
error, but works a treat.

"Libby" wrote in message
...
Hi Paul

try this

Sub hideworksheetswithblank()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Range("m7") = "" Then
ws.Visible = xlSheetHidden
Else
ws.Visible = xlSheetVisible
End If
Next

Bear in mind that you must have at least one sheet visible
in excel, so if you try and hide them all, an error will
occur.


-----Original Message-----
Hi Paul

Sub test()
With Sheets(3)
If .Range("M7").Value = "" Then
.Visible = False
Else
.Visible = True
End If
End With
End Sub

Now you figure out how to write into M7 when the sheet is

hidden ;-)


HTH. Best wishes Harald

"Skip" skrev i melding
...
Hello,

I have created a workbook with 21 worksheets. Quite

often, some of the
worksheets will not be required. Is it possible to

create a macro that
will
look for a value in a specific cell on a worksheet

(e.g. M7) and if that
cell is blank, hide the worksheet?

Grateful for any assistance.

Paul.




.



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
Hide a worksheet mac Excel Worksheet Functions 2 September 10th 09 03:00 AM
how to hide a worksheet deepika :excel help[_2_] Excel Discussion (Misc queries) 2 February 4th 08 01:38 PM
how to hide worksheet using VB associates Excel Worksheet Functions 1 June 15th 06 08:01 AM
How do I hide a worksheet in Excel and use a password to un-hide . Dchung Excel Discussion (Misc queries) 3 December 2nd 04 06:24 AM
Hide Worksheet STEVEB Excel Programming 2 November 12th 03 10:59 PM


All times are GMT +1. The time now is 10:16 PM.

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"