Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default Macro-Hide & Unhide Sheets with condition

Dear All,

I would really appreciate all the available help.

Scenario:
I have 30 worksheets including a Database and a Helper worksheet.

The 28 worksheets are made up of Individual Worksheets of Products:

Sheet 1: XYZ Group
Sheet 2: ABC Group
Sheet 3: TVR Group
Sheet 4: CIA Group
till Sheet 28.

What I wanna do:
a) If cell A1 of ANY Sheet (30 sheets) = 1 or True Then Visible

b) If cell A1 of ANY Sheet (30 sheets) = 2 or False Then Unhide

Result of the Macro:
If 3 items are purchased, then 5 worksheets are displayed:

a) 3 product sheets are displayed; and

b) 2 (database and helper)

I have inserted Alpha Numberic data in cell A1 of Database and Helper
Worksheet, so they are not affected by this.


Thanks for the help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default Macro-Hide & Unhide Sheets with condition

Apology for a mistake:

What I wanna do:
a) If cell A1 of ANY Sheet (30 sheets) = 1 or True Then Visible

b) If cell A1 of ANY Sheet (30 sheets) = 2 or False Then HIDE!!




  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro-Hide & Unhide Sheets with condition

Hi,

Hiding/unhiding sheets is doable but I don't understand the circumstances in
which you want to do it:

a) If cell A1 of ANY Sheet (30 sheets) = 1 or True Then Visible
How does the 1 get into A1 if the sheet is (presumably) invisible?

b) If cell A1 of ANY Sheet (30 sheets) = 2 or False Then Unhide
Is this not the same as a)?

Mike

" wrote:

Dear All,

I would really appreciate all the available help.

Scenario:
I have 30 worksheets including a Database and a Helper worksheet.

The 28 worksheets are made up of Individual Worksheets of Products:

Sheet 1: XYZ Group
Sheet 2: ABC Group
Sheet 3: TVR Group
Sheet 4: CIA Group
till Sheet 28.

What I wanna do:
a) If cell A1 of ANY Sheet (30 sheets) = 1 or True Then Visible

b) If cell A1 of ANY Sheet (30 sheets) = 2 or False Then Unhide

Result of the Macro:
If 3 items are purchased, then 5 worksheets are displayed:

a) 3 product sheets are displayed; and

b) 2 (database and helper)

I have inserted Alpha Numberic data in cell A1 of Database and Helper
Worksheet, so they are not affected by this.


Thanks for the help.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default Macro-Hide & Unhide Sheets with condition

Dear Mike,
Yup!! A mistake there!! should have been Hide. Sorry!!
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro-Hide & Unhide Sheets with condition

Hi,

Working backwards the will make any visible sheet hidden if a 2 is put in A1
of that sheet. Back to my original question. How is the 1 put in A1 to make
it visible again?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
For i = 1 To Worksheets.Count
If Worksheets(i).Visible = True Then
Visible = Visible + 1
End If
Next
If Target.Address = "$A$1" And Visible 1 Then
If ThisWorkbook.Sheets.Count 1 Then
If Target.Value = 2 Then ActiveSheet.Visible = False
End If
End If
End Sub


Mike


" wrote:

Dear Mike,
Yup!! A mistake there!! should have been Hide. Sorry!!



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro-Hide & Unhide Sheets with condition

Oops

try this instead, left a line in that didn't work

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
For i = 1 To Worksheets.Count
If Worksheets(i).Visible = True Then
Visible = Visible + 1
End If
Next
If Target.Address = "$A$1" And Visible 1 Then
If Target.Value = 2 Then ActiveSheet.Visible = False
End If
End Sub

"Mike H" wrote:

Hi,

Working backwards the will make any visible sheet hidden if a 2 is put in A1
of that sheet. Back to my original question. How is the 1 put in A1 to make
it visible again?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
For i = 1 To Worksheets.Count
If Worksheets(i).Visible = True Then
Visible = Visible + 1
End If
Next
If Target.Address = "$A$1" And Visible 1 Then
If ThisWorkbook.Sheets.Count 1 Then
If Target.Value = 2 Then ActiveSheet.Visible = False
End If
End If
End Sub


Mike


" wrote:

Dear Mike,
Yup!! A mistake there!! should have been Hide. Sorry!!

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default Macro-Hide & Unhide Sheets with condition

Dear Mike,

Forgot to thank you for your respond. Really appreciate it.

Here Goes:
In cell A1 of all 28 sheets, I was thinking of using a Reference formula,
IndexMatch(ing) from the helper worksheet.

In Cell A1 of Sheet 1-28
a) =if(iserror(index(Helper!B1:B100,Sheet1!B1,Helper! A1:A100,))),2,1)
b) Sheet1 B1=is a Worksheet name formula

That way, I can centralise control over the sheets. There will be lots of
hiding & unhiding (kinda dynamic). lol.

Please help me to write a macro for this. (I have tried the macro recorder,
clueless)

Thanks.


"Mike H" wrote:

Oops

try this instead, left a line in that didn't work

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
For i = 1 To Worksheets.Count
If Worksheets(i).Visible = True Then
Visible = Visible + 1
End If
Next
If Target.Address = "$A$1" And Visible 1 Then
If Target.Value = 2 Then ActiveSheet.Visible = False
End If
End Sub

"Mike H" wrote:

Hi,

Working backwards the will make any visible sheet hidden if a 2 is put in A1
of that sheet. Back to my original question. How is the 1 put in A1 to make
it visible again?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
For i = 1 To Worksheets.Count
If Worksheets(i).Visible = True Then
Visible = Visible + 1
End If
Next
If Target.Address = "$A$1" And Visible 1 Then
If ThisWorkbook.Sheets.Count 1 Then
If Target.Value = 2 Then ActiveSheet.Visible = False
End If
End If
End Sub


Mike


" wrote:

Dear Mike,
Yup!! A mistake there!! should have been Hide. Sorry!!

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default Macro-Hide & Unhide Sheets with condition

I will try out the codes. Thanks.


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 or unhide sheets based on cell billinr Excel Discussion (Misc queries) 2 July 13th 07 07:42 PM
Auto Hide-Unhide Columns with a macro Ed Excel Discussion (Misc queries) 0 March 8th 07 07:57 PM
Macro that will unhide then hide rows minka Excel Discussion (Misc queries) 10 October 21st 06 01:37 PM
hide/unhide macro Matt Excel Discussion (Misc queries) 2 April 6th 06 07:24 PM
How do I hide or unhide zero value columns/rows USING A MACRO? paul Excel Discussion (Misc queries) 1 January 23rd 06 03:06 PM


All times are GMT +1. The time now is 07:27 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"