VBA To Hide Columns Based On Formula

Sep 28, 2011

On my 'Report' worksheet in cells I1 to Z1 the formula returns "" if there's no data in that month or "1" to "18" depending on which month it is. e.g. if it's a 12 month accounting period then 6 of the columns will have no data in them and will have "" in row 1, the other columns will return 1 - 12 in row 1; if it's a 15 month accounting period then 3 of the columns will have no data in them and "" in row 1 and the other columns will return 1 - 15.

The VBA code below is part of a longer macro on my 'Data' worksheet. The rest of the code works fine and I just wanted to add this bit to hide the blank columns on the 'Report' page.

[VBA]
Private Sub Worksheet_Change(ByVal Target As Range)

Application.Calculate
With Sheets("Report")
Dim i As Integer
If Intersect(Target, Range("I1:Z1")) Is Nothing Then
Else
For i = 9 To 26

[Code] ........

View 4 Replies


ADVERTISEMENT

Hide Rows Based On Multiple Columns Formula Returning Empty Text ""

May 13, 2008

I would like to rows based on multiple column conditions criteria. ie., if the columns N, O, P values are "", then hide the particular row. The logic given in the website here, i tried But, it is not 100% working. It works for a few rows at the start of the database & it works for the rows at the end of the database. In between, for a few rows, even if the column values are "" it does not hide those rows.

View 2 Replies View Related

How To Hide Rows Based On The Value Of Two Columns

Apr 11, 2009

I need to filter out rows, based on a specific value in column A, (documents on file for the clients), then check column C (last name) and D (client first name), which can have the same client listed multiple times, based on how many different documents are on file ......

View 12 Replies View Related

Hide Columns Based On Cells Value?

Feb 24, 2012

macro below that will only hide columns if all the rows (e.g. row 8 to 18) have no value?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("U18:AB18")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub

[Code].....

View 8 Replies View Related

Hide Columns Based On Selection

Aug 30, 2008

I have a worksheet that lists the months of the year on row 3 from columns C through N.
What I am trying to do is to be able to select the month I want from a drop down list or combobox and then hide the remaining columns based on the selection. For example if JAN is selected the months FEB through to DEC would be hidden.

View 9 Replies View Related

Automatically Hide Columns Based On Dates?

Aug 4, 2013

I am trying to automatically hide columns based on dates. I have a set of dates ranging from the beginning of August this year until the end of December 2019. I am trying to hide all columns that are at least a day ahead of the current date. Today on 8/4/13 it would show all columns up until today along with tomorrow 8/5/13.

8/1/2013
8/2/2013
8/3/2013
8/4/2013
8/5/2013

View 2 Replies View Related

Code To Hide Columns Based On Value Of Another Column

Jul 31, 2014

with a simple code that could:

If column K2:k466 is blank or says "No" then columns L & M are hidden. If it says "Yes" it is not hidden.

Also,

If Column N2:N466 is blank or says "No" then Columns O,P,Q,R are hidden. If it says "Yes" they are not hidden.

Finally,

If Column V2:V466 has a zip code (or number) then columns T,U,W,X,Y,Z,AA,AB,AC are present. If there is no value in any of V2:V466 then they are hidden. .

View 12 Replies View Related

Hide Columns Based On A User Entry

Mar 28, 2009

Is there a way of a user can add a number in a cell and this would hide a different amount of columns.

OR :

Ideally I would prefer a drop down with dates and the user could select a forward date and all the columns with dates up to that would appear. This would mean they could look as far our as required and all unwanted data would be hidden.

View 4 Replies View Related

Hide & Unhide Columns Based On A Cell Value

Feb 21, 2010

worksheet I am working on at the moment, basically if row 5 has a 0 displayed I want that column to hide, but if row 5 has text of any value displayed I want it to unhide, the range is E5 to BA5 across.

I have draft VBA code as follows:

View 9 Replies View Related

Auto Hide Columns Based On Cell Value

Mar 12, 2012

I got an excel, with a "validation list" in a certain cell.

Users can select value1, value2 or value3. based on this value, some columns will have to unhide (standard= hidden)
(only for value2 this is the case).

I used the worksheet_change event to determin the value, but so far I'm only getting it to hide...

Code:

Private Sub Worksheet_Change(ByVal Target As Range)
If C24 = "value2" Then
Columns("H:O").Hidden = False
Else
Columns("H:O").Hidden = True
End If
End Sub

View 5 Replies View Related

Hide Rows Based Over Multiple Columns

Jan 29, 2013

a code that will search each cell across 4 columns and hide the row only if all cells are blank. The macro should search columns "b", "c", "e", and "f" to display all rows where at least one of the cells has a value.

Ex.

Col.B Col.C Col.D Col.E Col.F
1. 123 xxxxx 150
2. 56 xxxxx 50
3. (blank) (blank) xxxxx (blank) (blank)

In this ex. row 3 would be hidden.

View 1 Replies View Related

Hide And Unhide Columns Based On Cell Value

Mar 4, 2013

I need to write a macro that will hide and unhide columns based on a cells value. I know how to write it to hide and unhide rows, but i can figure it out for columns.

For the rows I am using the following:

Sub HideRowsSavings()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
With Sheets("Savings #4")
LR = .Range("A" & Rows.Count).End(xlUp).Row

[Code] ......

View 1 Replies View Related

Hide Columns Based On Cell Content

Apr 3, 2008

I'm sure this is an easy one, but I have never done this before. I need to know the best way to hide (for example) Columns U:W if cell U3 is blank.

View 9 Replies View Related

Hide Columns Based On A Cell Link

Nov 15, 2006

I need to hide columns in a spreadsheet without using the hide/unhide columns option. I found an article which suggested setting up a combobox from the forms toolbar, this is populated by an input range and linked to a cell for a numeric value. The article although using a macro to hide rows suggested this code


Private Sub ComboBox1_Change()

If ComboBox1.Value = "A" Then
ActiveSheet.Range("1:3").EntireRow.Hidden = True
ActiveSheet.Range("4:6").EntireRow.Hidden = False
ElseIf ComboBox1.Value = "B" Then
ActiveSheet.Range("1:3").EntireRow.Hidden = False
ActiveSheet.Range("4:6").EntireRow.Hidden = True
End If
End Sub

I want to amend this code so that when the number in my linked cell changes the various columns are hidden.

For example if the cell link number = 1 hide columns e to az if the cell link number = 2 hide columns d and f to az etc.

I have had varying success with amending this code to entirecolumn.Hidden and changing the Combobox1. to dropdown1. but am unable to get it to work, I also stupidly deleted the code that was partially working and am now unable to remember what I'd done.

View 9 Replies View Related

Hide/Unhide Columns Based On Cell Value

Sep 4, 2007

I've attached one speadsheet :- "VBA.xls". The following conditions are to be done:-
1. When D2=1, Column "F","G" are visible & Column "I","J","L","M" are hidden.
2. When D2=2, Column "I","J" are visible & Column "F","G","L","M" are hidden.
3. When D2=3, Column "L","M" are visible & column "F","G","I","J" are hidden.

View 9 Replies View Related

Hide Rows Based On Text Search In Three Columns?

Mar 22, 2013

I am working on a time management sheet for my company. I need to be able to click a button and have the file search 3 columns for a persons initials and then hide all the rows where the initials are not in at least one of the three columns. I seem to have no problem getting it to work for one column at a time, but as soon as I try to search more than one it all falls apart.

I will also need to create an unhide all button to reset the sheet after the macro has been run.

I have attached a sample of the sheet below. Each project needs to have 3 rows to show the schedule and budget broken down by each team member.

Project Number
Address
Service
PM
SS

[Code]....

View 5 Replies View Related

Hide Columns On Sheet2 Based On Cell On Sheet1?

Jan 25, 2010

This is what I would like to do if possible: If E9 on Sheet1 is 1, then hide columns F-L on Sheet2.

View 4 Replies View Related

VBA To Hide Columns Based On Input Date Range?

Mar 26, 2014

I need some VBA code to hide columns if they are outside of a specified date range.

- the worksheet i need to run this VBA on is named 'Summary'
- Columns A to G need to remain un-hidden at all times
- from H17 to ZZ17 i have every month of the relevant years listed (all there chronologically)
- D3 holds the 'Date From' variable
- D4 holds the 'Date To' variable

View 11 Replies View Related

Hide / Unhide Columns Macro Based On Cell Value?

Dec 7, 2011

I want to hide and unhide columns based on a cell's value.

If D6 of the ‘Summary’ Worksheet Is <> to ‘Test1’ and <> ‘Test2’
THEN Hide columns D:K of the ‘Charts – Source Data’ Worksheet
OTHERWISE Unhide columns D:K

View 4 Replies View Related

Hide And Unhide Columns Based On Cell Value From Lookup

Dec 4, 2013

I am trying to hide/unhide columns based on what is return to cell C2 from this lookup (=VLOOKUP(B2,GM!E2:M129,9,FALSE)). It can only return 3,6 or 9

If it returns 3 I want to hide columns I:P
If it returns 12 I want to hide columns E:L
If it returns 6 I want to hide E:H and M:P

I have been trying to work with this code which I found on this forum but I haven't been able to get it working fully. It only works when C2 is entered rather than calculated and I can't get it working for the M:P part of the third option.

Code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range
Set Changed = Range("C2")
If Not Intersect(Target, Changed) Is Nothing Then
Range("A:Z").EntireColumn.Hidden = False

[Code]...

View 1 Replies View Related

Hide A Rows/columns Based On A Cells Contents

Jun 30, 2006

way to automatically hide a row or column based on a specified cell.

Or even something general like: Hide all rows with cells evaluating to #n/a.

View 9 Replies View Related

Hide/unhide Number Of Columns Based On Cell Value

Jul 17, 2007

If I have a value in A1 and run a macro [button], I want to have it hide a number of rows.

Each number is one column.

eg if A1 = 2 then B:C are visible, D:IV Hidden
if A1 = 3 then B:D are visible, E:IV Hidden
if A1 = 4 then B:E are visible, F:IV Hidden

up to 200 columns.

I tried it as a select case, but it is limited to just 22 cases which obviously not enough.

View 9 Replies View Related

Unhide/hide Multiple Columns Based On Date

Jul 30, 2007

I need to show hidden columns based on the date I entered. For example, if I entered "1/1/1990" on a1 as the starting date and "4/30/1990" on b1 as the ending date. I want Excel to show the columns that are covered by the date, thus it shows Jan, Feb, March and April. How do I do that? Here's an example attachment. In here Sheet 1 is the starting point, the highlighted cells is where I enter the date. the Result sheet shows what I want Excel to show me when I have a date entered.

View 8 Replies View Related

Hide Columns In Sheet Based On Value In Double Clicked Cell

Jun 4, 2014

I have a workbook with two sheets, Project Overview and Projects Detailed. In Project Overview column K is different project numbers and what i need the code to do is when this number is pressed it has to go to Projects Detailed and search for this number in column AV and hide the lines that does not correspond with the number that has been double clicked.

In project overview you should only be able to press the numbers from row 9 and down and in Projects Detailed the numbers in column AV also starts in row 9. Some of the cells in column AV are empty and these should also be hidden.

View 2 Replies View Related

VBA To Hide / Show Columns Based On Filter And Multiple Criteria

Mar 8, 2014

I have a very large table and i need to be able to Hide/show specific ranges based on:

Filter +and+ specific cell values in columns

brief example of the table : tablee.png

So...
1. Filter Column "B" (in this case we select "HELPING")
2. Auto hide/show collumns. - IF "C1" = "Required" THAN Show "C:E", IF "C1" ="N/A" , HIDE "C:E" and so on for every column like above.

There are over 80 columns like the "C:E" range. and I only need to show those that are "Required".

View 1 Replies View Related

Hide / Unhide Rows And Columns Based On Several Date Ranges

Mar 19, 2014

I am building a sheet to display deadlines (rows) by project (columns). I would like to have it automatically hide the rows and columns based on the date of the deadline. If the deadline is today or 1 week from today the associated rows and columns should be visible, otherwise, I would like to hide them.

My table is A1:N9, with A1 being a blank, row names A2:A9, and column names B1:N1.

View 4 Replies View Related

Hide/unhide Columns Based On Dropdown List Answer

Sep 26, 2008

I am a newbie to Excel. I really appreciate if someone could help me here and this is very urgent as I have a project going on.

I have a cell say B3, which is a dropdown list I created using Data Validation. It only lists down Yes or No.

What I need is when you click on Yes in B3, i need columns C to I to unhide. If answer is No, column C to I should be hidden. By default, the columns will be hidden.

Can you please help? I tried many times but not successful. Appreciate if someone will be able to walk me through details. If you want to see the sample spreadsheet, I can sent it to you by email. I tried Data> Outline group but they are not happy with this.

View 9 Replies View Related

Hide Unwanted Columns & Clear Ranges Based On Cell Value

Sep 17, 2008

I have written a VBA procedure which is supposed to hide unneeded columns (based on the a number entered in a certain cell. This is working so far. Since I need to sum only the visible cells in a row i need to clear the contents of a range of cells if they will be hidden. Unfortunately the code i have written runs only to the ClearContents and then starts over from the beginning. If i take out the .clearcontents and put .Select for example instead, the code runs perfectly.
Here is the

Sub worksheet_calculate() 'Hide columns that are not needed

Sheet1. Unprotect

Application. ScreenUpdating = False

Dim i As Integer
Dim r As Integer
Dim s As Integer
Dim rngRange As Range

i = 2

View 8 Replies View Related

Automatically Hide/Unhide Columns Based On Cell Text

Jan 10, 2009

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 13 Then Exit Sub
If InStr(Target.Value, "Other (specify in next column)") Then
Columns("N").Hidden = False
ElseIf WorksheetFunction. CountIf(Columns("M"), "Other (specify in next column)") = 0 Then
Columns("N").Hidden = True
End If
End Sub

but I have a lot of columns that I need to perform as above and I have put the code together as below

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next

If Target.Column = 13 And InStr(Target.Value, "Other (specify in next column)") Then
Columns("N").Hidden = False
ElseIf WorksheetFunction.CountIf(Columns("M"), "Other (specify in next column)") = 0 Then.................

Using the above code, when I selected more than one cell anywhere in my workbook and pressed delete I was bugging out with a runtime error 13 message. You can see from the above code that I inserted "On Error Resume Next" - this got rid of the runtime error 13 message, but now when I select more than one cell and press delete, hidden columns are incorrectly revealed in my worksheet. how I can extend the working code at the top of this posting so that it works for a number of different columns in my Worksheet i.e. without the runtime error 13 occurring and without columns being incorrectly revealed.

View 8 Replies View Related

Hide Columns Based On Date Value In Cell (Worksheet Change Event)

May 23, 2014

Hide Columns based on Date value in cell (Worksheet Change event)Looking for a worksheet_change event macro that will automatically hide columns based on a value in cell S3. S3 is a data validation pick list of months based on the 1st day of each (e.g. 1/1/2014, 2/1/2014, 3/1/2014, etc.). I have date columns in row 6 from columns T through AQ. These values are 1/1/2014 (T6), 2/1/2104 (U6), 3/1/2014 (V6)....12/1/2015 (AQ6). I would like to hide columns that have a date in row 6 (T6:AQ6) that is LESS THAN (<) the date in S3 after the cell is value is changed.

View 2 Replies View Related







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