Hide / Unhide Worksheet - Code Is Not Working?

Aug 4, 2014

Within a worksheet "Page_2" I would like VBA to perform following calculation: IF(COUNTIF(R:R;1);1;2)

Basically, look into column R of worksheet "Page_2" and look if there is in the column at least one number with the value 1, if there isn't show me value 2.

Depending on the value coming out of this function, VBA needs to hide worksheet "Page_3" if the value is 2 and unhide worksheet "Page_3" if the value is 1.

Here is the code which I'm using and that is not working.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.WorksheetFunction.CountIf(Range("R1:R5000"), 1) = 1 Then
Worksheets("Page_3").Visible = True

[Code]...

View 2 Replies


ADVERTISEMENT

Code TO HIDE Or UNHIDE Row

Jul 24, 2007

I am using the code below on my spreadsheet. What is does is hides Row #1 until Row 41 is reached. When 41 is reached Row 1 appears. Unfortunately (for me) I need to alter this code and was wondering if anyone could tell me if it is possible. First the
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Rows(1).Hidden (Target.Row < 41) Then
ActiveSheet.Unprotect
Application.ScreenUpdating = False
Rows(1).Hidden = Target.Row < 41
ActiveSheet.Protect
Application.ScreenUpdating = True
End If

End Sub

What I would now like to happen is that Row 1 stays hidden UNTIL Row 16 is OFF Screen. Can that be done? What has happened is that my row 16 contains the heads for my input table. I have now had to set the rows to resize to accommodate data input. If no rows are resized then Row 16 stays visible until I reach row 40. When row 41 is reached then Row 1 appears which contains my headers as well. I hope this makes sense to someone...

SO, IF I can get a code that would keep row one hidden until Row 16 is off screen then it will not matter what rows expand.

View 9 Replies View Related

Hide And Unhide Worksheet

Mar 30, 2004

I put the correct cell in place $K$23, now I want to hide a worksheet called "DutyCode" when info!$k$23 is blank or has "xx" or "XX" in the cell, and then unhide "DutyCode" when the number 27 is inputed in info!$k$23

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address "$k$23" Then Exit Sub
If Target.Value = 1234 Then
Worksheets("Sheet2").Visible = True
Else
Worksheets("Sheet2").Visible = False
End If
End Sub

View 5 Replies View Related

Code To Hide/Unhide CommandButtons

Oct 21, 2008

I have a file which contains many worksheets with many buttons on them for doing administrative work when updating data. I want to be able to click on a button on my "admin" worksheet to hide all the other buttons on the other worksheets. This is hide the buttons from the view of 'readers' so that they will not be tempted to click on a button to see what it might do. I have tried several different variation of coding, but can not seem to get the "right" object to work with so as to set the code to be xxxx.visible=false. I seen references to Shapes, Shape, Control Toolbox buttons objects, CommandButton, etc.

I would really appreciate if someone could give some pointers on how to designate in VB code, which will lend itself of future updates, the following:

in a toogle button, loop through the series of worksheets making each command button on that sheet set visible = false. Then for the other portion of the toogle repeat the process, but set visible = true.

View 6 Replies View Related

Worksheet CheckBox (Hide Unhide)

May 22, 2009

I am having difficulties with this one. I have a button on my worksheet (sheet1) that runs a macro.

View 4 Replies View Related

VBA Code To Hide Unhide A Number Of Rows

Sep 15, 2004

I am trying to create an input sheet with a specified number of rows. My plan was to hide all the empty rows in the table and ask how many rows were required in the table. A button would then be pressed to unhide all the relevant rows thus giving a table of the correct size. My best effort so far looks something like this:

Sub UnhideRows()
Dim i As Integer
Dim myRow As Integer
myRow = Range("A1") + 2
Application. ScreenUpdating = False
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction. Sum(Selection.Rows(i)) > myRow Then
Selection.Rows(i).EntireRow.Hidden = True
End If
Next i
Application.ScreenUpdating = True
End Sub

the cell to give the size of the table is A1 and the table starts in A3. The first cell in each row has an index number (=row() - 2), all other cells would be empty to begin with. My attempt did not work.

View 5 Replies View Related

Excel 2010 :: VBA Code That Will Hide / Unhide A Row When Used With Checkbox

Jun 22, 2014

I need a VBA code that will when used with a Form Control "Check Box" will unhide / hide a row. To be more exact, I'm needind the code to "Hide" row 34 when unchecked and "Unhide" the same row when checked. I'm using Excel 2010.

View 9 Replies View Related

Macro To Hide / Unhide Worksheet Based On Cell Value

Jul 18, 2010

I would like to create a macro/vb code that will unhide a worksheet if cell value is greater than zero, or hide the worksheet if the cell value is zero.

I'm not too familiar with VB code and was wondering if this is possible? I have my doubts, since it means that the code must constantly be running in an endless loop, checking to see if the value has changed?

View 9 Replies View Related

VBA Script To Hide And Unhide Specific Columns Within A Worksheet

Oct 24, 2006

Need the VBA script to hide/unhide specific columns within a worksheet.

View 9 Replies View Related

Code To Unhide A Worksheet Link To Value In Cell

Feb 5, 2012

I have a workbook with daily sales information for each week in a period (4,5 or 6 weeks) depending on the fiscal year calendar. I have a dashboard to select the weekending date in cell D7. I used mscal 7.exe to embed the calendar. I need the date to remain the same, but want the calendar to show the current date. Cell H5 shows the current period;i.e. 1,2,3,4 etc. Cell H7 shows the week number of the period (1,2,3,4,5 and 6 for December).

I need vba code to showthe appropriate week's daily sales worksheet based on the info in cell H7 on the dashboard. The week number on the dashboard page is obtained fromthe calendar worksheet with a vlookup formula. These sheets are named "week 1, week 2, week 3, week 4, week 5 and week 6". I need to assign this code to a shape with the caption Create New Week.

View 1 Replies View Related

PASSWORD/Code To Unhide Rows And Worksheet Tab

Jun 15, 2007

I have a protected sheet so specific people can only see certain things. I would like code to Unhide a tab called "Estimating" and unhide Rows 2 through 9 and rows 24, 26 and 27.

View 9 Replies View Related

Hide / Protect Worksheet Code

Jul 9, 2007

I need to be able to save a copy of my spreadsheet but protect the structure so that the hidden rows cannot be opened by the person that I e-mail it to. At the moment I am using the current

Private Sub CommandButton2_Click()
Do
fName = Application.GetSaveAsFilename
Loop Until fName <> False
ActiveWorkbook.SaveAs Filename:=fName
Call ProtectRobin
End Sub
Private Sub ProtectRobin()
ActiveWorkbook.Protect ("Robin")
End Sub

The saving part of the macro is working perfectly, however I cannot get the protection to work. It must have a password - I do not want the receipient to be able to go 'Tools' > 'Unprotect Sheet'.

View 6 Replies View Related

Code Stopped Working - Can No Longer Copy And Save Worksheet

Jul 31, 2012

I have been working on this application for the past couple weeks and I have this module of code that copy's a worksheet into a new workbook and changes everything into values. However I have added buttons onto this sheet and after running the code again it froze the program, in which I had to manually end. It gave an error afterwards however I don't remember what it said. Now everything I try to run or step through it, nothing happens. And I have turned Events and ScreenUpdating on.

I would also like to note that it won't allow me to perform actions like unhide sheets or unprotect them. The code has not been changed either so what has happened to disable all functionality.

[URL] .....

View 1 Replies View Related

VBA / Code Stopped Working - Can No Longer Copy And Save A Worksheet

Jul 30, 2012

I have been working on this application for the past couple weeks and I have this module of code that copy's a worksheet into a new workbook and changes everything into values. However I have added buttons onto this sheet and after running the code again it froze the program, in which I had to manually end. It gave an error afterwards however I don't remember what it said. Now everything I try to run or step through it, nothing happens. I have turned Events and ScreenUpdating on.

View 2 Replies View Related

VBA Code To Hide Columns To Left And Center Worksheet

Sep 4, 2013

I have a worksheet in excel that I have hidden columns from AA right to the end. Which gives the user a nice worksheet with everything to the right of AA hidden in blue. What I would like to do is now centre the worksheet in the screen and have the same hidden blue effect to the Right of the worksheet in this blue.

View 1 Replies View Related

Excel 2010 :: Hide Worksheet Password In VBA Code Without Project Protection

Nov 5, 2012

I have a 2010 excel workbook with several locked worksheet (to which I manage the PW). I and another staff member manage different section of the macro but the other staff member doesn't have access to the locked areas.

Is there a way I can encrypt the password within VBA so it's not visible to the other staff member?

Locking the VBAProject doesn't work as the other staff member has to be able to edit his VBA section.

Many staff run the macro (via a button) and don't need to access the Macro and don't have access to the protected sheets.

I understand excel isn't ideal with PW protection for people wanting to bypass the protection and this isn't an issue.

View 3 Replies View Related

Hide / Unhide One Row At A Time?

Dec 1, 2012

I have this file in which I have 25 empty rows in between different categories. On the side of each category there is a plus sign which is supposed to unhide an empty row below the last used one, and a minus sign which should hide the last empty row within the category (i.e. mobilization, earthworks...). I faced many problems and tried to simplify it as much as possible (trying the code for only one category, msgboxes with the values to understand what was going on) but no luck. The problem that I have been stuck at the moment is that when I try to count the rows from C73 to the last used row, it bypasses the hidden ones. I have a mess of a code and a print screen which I am attaching. printscreen.jpg

VB:
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim rInt As Range

[Code].....

View 3 Replies View Related

Hide Row Based On 0 Or Unhide When Less Than 0

Oct 16, 2013

Trying to hide a rows based on value being inserted to A1 = 0 (if value is >0, then unhide), but it's not working.

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 0 Then
Rows("33:42").EntireRow.Hidden = True
Else
Rows("33:42").EntireRow.Hidden = False
End If

View 6 Replies View Related

Hide / Unhide Certain Rows

Apr 3, 2014

I highlighted a selection of rows and clicked HIDE, now I want to unhide certain rows and when I highlight the rows above and below and right click - unhide nothing happens. I need to Unhide to find something.

View 2 Replies View Related

Hide/Unhide The Columns

Jun 16, 2009

I've come across a spreadsheet where certain rows and columns (typically top rows or left columns) are hidden; however, there's no way to unhide them (the unhide function is grayed out) and it doesn't seem to be protected or no visible macros/vba on the file.

View 3 Replies View Related

Number & Row Hide/unhide

Sep 11, 2009

when i type 100 in the cell & press enter it automatically change to 1..and when i type 1000 i change to 10.

i have select B1 to B5 then hide it.then i click A1.how do it unhide it?

View 5 Replies View Related

Hide And Unhide Sheet According To A1 Value?

Apr 11, 2014

i want to hide my sheet if A1.value = 0(zero) and if unhide the sheet if A1.value = greater than 0(zero)

View 11 Replies View Related

VBA To UnHide / Hide Sheets

Feb 20, 2014

I have a workbook with about 20 worksheets in it.

6 are visible
3 are hidden

the remaining are very hidden

I'm creating a "welcome" page to the workbook with instructions on how to update data. The data between the 20 sheets consists of pivot tables, charts and summary data. The Visible sheets are data for management's review (all protected). The 3 hidden sheets are pivot tables that the user needs to pull data from and the very hidden sheets are not to be seen by anyone.

In my "welcome" page, I added the instructions of how to update data, but wanted an area where I could assign a checkbox or button to click on for the user to unhide my 3 hidden sheets (say Sheet1, Sheet2 and Sheet3). I do not want it to unhide my very hidden sheets. Then, when the information needed is retrieved from those sheets, I would like the user to use a checkbox or button to hide the 3 hidden sheets again. Is there a way to do this?

I tried creating custom view but couldn't do that because of the pivot tables (the option was disabled). I'm a beginner in VBA so don't even know how to begin.

View 6 Replies View Related

Hide/Unhide Columns

Dec 19, 2008

I have a spreadsheet that has 28 columns for time entries. Typically only the first 12 columns are used, so I would like to hide the remaining 16 columns (which makes the spreadsheet much more user-friendly). It would probably be nearly impossible to teach all of them how to Unhide the remaining columns (and re-Hide), plus I would like to use the full-screen function when employees enter thier times. I would like to use a form control in the column heading so that when the employees 'check' it, it will Unhide and then re-Hide the columns. Any way to do this? Seems like a VB thing to me (out of my league, but would be happy to add one in!).

View 2 Replies View Related

VBA To Unhide And Hide Columns?

Oct 23, 2002

I want to create two buttons.. one name HIDE and the other UNHIDE.

What I need hide button to do when i click it is hide the 4 columns to the right (not always going to be columns b:e)

For the unhide button unhide the 4 columns to the right (not always going to be columns b:e)

View 9 Replies View Related

VBA To Hide / Unhide Tabs

Dec 11, 2011

I am looking for a way to hide and unhide tabs. The first sheet of the workbook is an information sheet and I have a dropdown box in cell N3 to select Yes or NO to correct financial issues. If I select NO I would like to also hide tabs for sheet 4 and sheet 22.

I have used this for hiding rows:

If ActiveSheet.Cells(2, 2).Value = 0 Then Rows(146).Hidden = True

Can this be adapted to hide tabs?

View 8 Replies View Related

Hide / Unhide Columns By The Use Of + And -

Mar 5, 2013

I once saw an excel sheet where I could hide or unhide a section by some + and - signes above the column-letters.... I have searched for this but I only get the ordinary hide/unhide solutions.

View 4 Replies View Related

Hide/Unhide Toggle

Jan 8, 2007

Could someone provide me with the VBA to 'toggle' between HIDING and UNHIDING columns within one macro

e.g. toggle between this hiding and unhiding the following

Sub HideColumns()

Range("G:G,I:I,AB:AV").Activate
Selection.EntireColumn.Hidden = True

End Sub

View 9 Replies View Related

Macro To Hide/unhide A Row

Sep 23, 2007

I made this simple little macro to hide/unhide a row on a different sheet based on a check box. The row hides fine. The problem I have is unhide. I uncheck the box, but the row stays hidden. What am I missing to make this little gem come to life? This is for tracking popcorn sales for scouting and I'm trying to make it as easy to use as possible.

Sub Patrol1_Scout1()
If True Then
Sheets("Show_n_Deliver_Sold").Rows("7:7").EntireRow.Hidden = True
End If

If False Then
Sheets("Show_n_Deliver_Sold").Rows("7:7").EntireRow.Hidden = False
End If
End Sub

View 9 Replies View Related

Hide/Unhide Row Event

Jan 10, 2008

It seems there may be an event or something that happens when a row is hidden/unhidden.
I have this simple function that gives TRUE / FALSE if the Cell's Row or Column is Hidden.

Public Function IsVisible(MyRange As Range)
IsVisible = ((Rows(MyRange.Row).Hidden = False) And _
(Columns(MyRange.Column).Hidden = False))
End Function
And a formula in a cell
=IsVisible(A1)

When I hide/unhide the ROW - the formula recalculates automatically without having to do the F2 Enter thing..

But when I hide/unhide the COLUMN, it does not recalculate automatically. I have to do the F2 Enter thing to get it to recalculate.

Even putting Application.Volatile in there doesn't do it.

I'm just curious why it recalculates when the row is hidden/unhidden but not when the column is hidden/unhidden? Is there a hidden event that could be used? I often see posts of people trying to prevent hiding rows.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved