Hiding Empty Columns In Range

Jul 3, 2014

I am trying to hide columns in a range, "P8:ET1087" but it isn't working. After I autofilter a value, every row will be hidden except for the rows where the value is found. This is always 6 rows, won't be more or less.

The 6 cells in every column are the same and contain from 1 to 6:
Text
Text
Date
Number
Text
Date

What I am trying to do is to hide the column if all cells in that column are blank/empty after it's autofiltered. That for the 135 columns, from P to ET.

I was messing around with the following code:

[Code] .....

But it doesn't seem to work.

View 4 Replies


ADVERTISEMENT

Macro For Hiding Rows Containing Empty Cells Through Different Columns

Sep 4, 2013

I created a macro that analyzes some datasets and according to different parameters it puts an X at the side of every cell that goes out of parameters. These Xs are all in columns named the same way for it to be easier to find. What I want to do is to write some macro that will hide every row where the data did not go out of parameters to be able to easily see where it did. In the following example it would need to hide the second row since there are no Xs in that row. One of the problems I'm having is that the amount of columns and rows is variable.

Data
Data
Functional Upset
Data
Data
Functional Upset

#
#
X
#
#

[Code] .......

Below is the piece of code that I created to try to do this (G has the value for the amount of rows). I think it is working but it is either taking too long since it has to sometimes go through over 20k lines as much times as it needs to to cover all the rows that contain Xs or its getting stuck for some reason.

Code:
Worksheets(2).Range("I3:I" & G).EntireRow.Hidden = True
K = 0
Do Until Worksheets(2).Range("I1").Offset(0, K) = ""
If Worksheets(2).Range("I1").Offset(0, K) = "Functional Upset" Then

[Code] ......

View 6 Replies View Related

Remove Empty Rows Based On Range Of Columns If Columns Are All Empty (no Data) Delete

Oct 24, 2012

Using the following code to remove empty rows based on whether a specific range of columns is empty. The code works if the cell has a zero, but not when the cell is blank. An example of the data is attached.

VB:
Public Sub DelRows2()
Dim Cel As Range, searchStr, FirstCell As String
Dim searchRange As Range, DeleteRange As Range

[Code].....

View 1 Replies View Related

Hiding Columns: Unable To Set The Hidden Property Of The Range Class

Oct 31, 2006

I have recently tried to implement the password protect from viewing code from this site. It worked brilliant on a basic spreadsheet, but when I tried to implement it on a worksheet with links I keep getting the error:

Run-time error '1004'
Unable to set the hidden property of the Range class

View 9 Replies View Related

Hiding Cells If Empty

Jan 21, 2010

I was wondering what would be the best way to go about hiding either rows or columns based on whether a particular cell is empty or not. The reason being, I want a graph and table to only display data when present.

View 14 Replies View Related

Hiding Of Empty Rows

Apr 26, 2006

How do I go about hiding empty rows in a separate linked sheet? To be more precise, I'm working on 2 sheets now. Sheet 1 would be the input sheet and sheet 2, the output sheet. For instance, there are 10 rows of data in Sheet 1, but out of this 10 rows, I planted data only into 4 rows. How do I ensure that Sheet 2 hides the empty rows (5th - 10th)?

View 2 Replies View Related

Hide Columns If All Cells In A Range Are Empty

Jan 17, 2010

I am looping thur an array to Format A range of cells. After the format is complete I need to validate that all of the cell in a range are empty if so hide the whole Column.I was Try to do it like this. I am not getting an error but nothing seems to happen either. Also The Boder of the cell only appers on the Last cell it should be on the cells....

View 3 Replies View Related

Hiding Empty Rows Via VBA Code?

Jul 10, 2014

automatically hiding empty rows on my table... though the table has been referenced via string of formulas which I added up on my worksheet.. Some of the rows on my table are empty and I tried a VBA code on automatically deleting the rows but then I realized that if that certain 'referenced' string of that cell is not empty anymore, that would cause me much trouble.. so basically I need a code that would automatically hide the rows that displays a result of "" and unhides when it is not empty.

View 14 Replies View Related

Hiding Answer To Formula If One Cell Is Empty

Nov 5, 2009

Is there a way to have the answer to a formula display nothing if one of the cells have nothing. Example cell A3= A1*A2 ... it will naturally show 0.00 but even if both A1 and A2 are completely blank. Is it possible for A3 to show nothing if A1 or A2 or both contain nothing. I still want it to show 0.00 but only if that’s what is in the other cells.

View 5 Replies View Related

Delete Empty Rows And Empty Columns From Word Table

Mar 25, 2014

I am trying to populate the 2 tables from excel to word. I will be getting the excel file with tables in various sheets. One sheet consist of 2 tables that will be inserted to one word document. So if there are 2 sheets then I will have the tables inserted in the 2 word document. In the excel sheet I have attached, there are 2 sheets with tables in each of them. I have written the code to copy and paste the table to word doc from (general) range A1:G4 (Table 1) and A9:H18 (Table 2) that has empty rows and columns selected. But there are empty rows and columns inserted since the table range is not same sheetwise. I would like get the empty rows and columns deleted in the word table.

Find the attached sample excel sheet and the word documents.

DeleteEmptyRows(Sample).xlsx‎
Sheet1.doc‎
Sheet2.doc‎

View 2 Replies View Related

Returning The Contents Of A Non-empty Cell In A Range Of Empty Cells

Jan 8, 2008

I have a long range of cells (U3:AX3), all of which are empty save one. Is there a way to search through the range of cells, and return the contents of the one cell that contains text?

I would do this with a series of nested IF statements if there weren't more than 30 of them!

View 9 Replies View Related

Hiding / Showing Columns ....

Jul 7, 2008

Here's what I'm trying to do -

There's a sheet called "Main" and 38 other sheets that shows the data (these 38 sheets all have the exact same structure/layout). Let's say these 38 sheets are called "country1", "country2", .... "country38".

Based on user input in cell J10 in "Main", I want to show only the relevant columns in all of the 38 country sheets. Specifically,

If J10 in sheet "Main" = "Option 1", hide all columns in all 38 sheets except columns A to W.

If J10 in sheet "Main" = "Option 2", hide all columns in all 38 sheets except columns Y to AU.

If J10 in sheet "Main" = "Option 3", hide all columns in all 38 sheets except columns AW to BS.

If J10 in sheet "Main" = "Option 4", hide all columns in all 38 sheets except columns BV to CQ.

If J10 sheet "Main = "ShowAll", show all columns in all 38 sheets....

Cell J10 in "Main" will be a drop down bar with the 5 choices.....

View 14 Replies View Related

Hiding Variable Columns

Mar 30, 2009

I have a spreadsheet with dates runnung from column D:IV,

I am running a simple macro but need this macro to hide columns D to whichever column is yesterday's date.

View 5 Replies View Related

Hiding Columns Based On Value

Sep 8, 2013

I have a spreadsheet that I'm trying to hide specific columns. In Row 6 I have the day of the week (Sun thru Sat) and Row 7 with the respective date starting in column F to column ZZ.

I would like to hide all columns with Saturday and Sunday in row 6. I tried using VBA but I'm new to coding and can't figure out the correct syntax.

View 4 Replies View Related

Hiding All Columns That Contain Only Zeros And / Or 1s?

Oct 1, 2013

I have a large table with an unknown number of columns and an unknown number of rows. The table contains no formulas and no errors - only text, numeric values and empty cells. The top row contains text (headers).

Column I contains below the header only zeros and/or 1s. However, a few entries in Column I might also be empty cells. Same is true for columns I+4 (i.e., M), I+8 (i.e., Q), I+12 (i.e., U), etc.

How could I hide ALL such columns (i.e., I, M, Q, U, etc.) with a VBA macro?

View 7 Replies View Related

Hiding Columns With Zero Value In Table

Nov 23, 2006

I was wondering if there was a simple function that will hide all the columns which have Zero value thoughout a pricing spreadsheet.

The different elements of the pricing have lead to 60+ columns, upto 75% may not contain a value or may display "false", it is making it very difficult to view and print. At present I am manually auto filterig to see if values are present in the column and then hiding the columns if they are blank (a real pain in the backside).

View 9 Replies View Related

Hiding / Unhiding Columns

May 20, 2007

I have a spreadsheet that i would like to hide all columns from B:M and to select the column/s I want to unhide.

I would like VBA cose to do this or to set up a combo box that will allow me to hide/unhide specific columns....

View 9 Replies View Related

Hiding Columns With A Cell Value Of 0

Dec 13, 2003

I need help on hiding a row if a cell value is 0 in a column

View 5 Replies View Related

Hiding And Showing Columns

Jan 18, 2007

I have a some simple code that doesn't seem to want to work ALL the time. Granted, sometimes it works but not always. The first code is to hide a bunch of columns and the second is to display those again. I put in the If/Then to avoid trying to hide columns already hidden (I thgouht that had to be done - true). Anyone see any problems with this code. The error I get is:

"Run-time error '1004':
Unable to set the hidden propoerty of Range class. I get it at

If wb.Worksheets("Growth").Columns("ap:iv").EntireColumn.Hidden = True Then
wb.Worksheets("Growth").Columns("ap:iv").EntireColumn.Hidden = False 'Error is on this line
End If..............

View 6 Replies View Related

Multiple Statements For Hiding Columns

Jan 20, 2009

I'm running a macro with multiple statements for hiding columns, and it has been running well for years, now today i'm getting a error message in the macro while debugging that states "Unable to set the Hidden property of the Range class", and when I reset the macro, and try to manually hide the range, I get the error message "Cannot shift objects off sheet".

View 2 Replies View Related

Macro For Hiding Columns & Printing

Dec 2, 2008

Iam an accoutant and have been given a task we have a workbook we use monthly that has about 50 columns, we have to go in and hide all the columns we do not need to print so I am wanting to create one that will hide the neccessary columsn print, unhide the columns and then hide the neccessary ones and print and so and so on.

I tried to do this by recording a macro and it sent me to visual basic and now says ithas all of these errors and i dont know how to fix them i need to do this porbabaly for about 20 different hiding and printing combinations. I am going to attach the errors i am getting when i try to debug in visual basic this is just for the first combination so i guess i need to know how to do debug for the rest of the combiantions. I am also hiding the entire column i dont know if i should be or not. I am attaching the file that i am doing the hising in as well. So like for the first i need to only keep column a,b,c (always unhidden) and then g for this time, print, unhide, then again column a,b,c active, then column u print and then unhide and on and on.

View 2 Replies View Related

Hiding Columns Based On Cell Value

Aug 7, 2011

I am trying to hide columns where the Value in the cells on row 9 is "", that cell being populated with a formula where the result is "". However I am getting the Compile Error Message 'Next without For'. Any clues?

Sub GraphC()

Dim a As Integer
Dim ColumnVar As Variant

ColumnVar = Array("B", "C", "D", "E", "F", "G", "H", "I", "J", "K")

[Code] .........

View 8 Replies View Related

Hiding Worksheet Columns Using Listbox?

Oct 14, 2011

using VBA in excel. My questions is: I would like to make a listbox that has 1 column and shows all of the headers in my different worksheet columns, and I would like to hide the columns based on which ones are selected in the listbox, is this possible I am having trouble findings examples online.

View 9 Replies View Related

Hiding Columns With Dates In Any Cell

Nov 17, 2011

Trying to hide columns that have a date in any cell: cell < TODAY() Or cell - 30 < TODAY()

Code:
Dim row As Range
Dim cell As Range
Dim col As Range

Dim lRw As Long

[Code] .......

View 9 Replies View Related

Hiding Multiple Ranges Of Columns With VBA?

Nov 24, 2012

I'm trying to hide groups of columns on a dropdown change. I'm extremely new to VBA, so I'm having a bit of trouble understanding some things. Here's what I've got so far...

Code:
Private Sub modeList_Change()
Dim selectedMode As Integer
Dim selectedOpp As Integer

[Code]...

I recognize my main problem is the assigning the multiple ranges to be hidden to the leadColsArray.

View 2 Replies View Related

Hiding Some Not All Rows / Columns With Headings

May 18, 2014

How do I get the effect of hiding unused rows/column in the sheet, including headings, while the parts in use still display headings?

The pick below explains what I mean. [IMG][/IMG]

View 2 Replies View Related

Offset Hiding Columns Macro In VBA

Aug 1, 2006

I am attempting to creating a Macro in excel with an offset feature but I am having trouble getting it to work correctly. I will include what I have created thus far, but this is what I would like it to do. There are 2 columns, A and B which are header columns for rows 2 through 75. Columns C through G contain values which are referenced in formulas in the corresponding cells in columns H through the end of the sheet. Ideally after every day I would like to run the macro to hide the next 6 columns which are showing. So on day 1 I want to run the macro to hide columns H through M. On Day 2 I would like the macro to offset and hide the columns N through S and so on. Each day an additional 6 columns (which is the all the data for the previous day) need to be hidden so that the current day's data is showing and can be easily read alongside the headings which flow vertically down columns A and B. If you could please help me with the proper form of this macro I would greatly appreciate it. This is the current macro I have made, I would like to add an offset command in there but am unsure which line to tie it to:

Sub HidePreviousDay()
'
' HidePreviousDay Macro
' Hide the Previous 6 Columns (the entire last day)
'
' Keyboard Shortcut: Ctrl+Shift+H
'
Columns("H:M").Select
Range("H2").Activate
Selection.EntireColumn.Hidden = True
End Sub

View 3 Replies View Related

Hiding Rows And Columns At The Same Time

Aug 17, 2006

I have a macro that works great to hide rows with zeros in a specific column on one sheet. It is below:

Sub Hide_Rows()
Dim i As Integer
ActiveSheet.Unprotect Password:="Yourpassword"
Application. ScreenUpdating = False
Application.Calculation = xlCalculationManual
For i = 9 To 408
If Sheets("Tasks and times"). Range("H" & i).Value = 0 Then
Rows(i & ":" & i).EntireRow.Hidden = True
End If
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="Yourpassword"
End Sub

My problem is that now I want to adapt it to also hide columns on another sheet in the same workbook (named OBS). This is because in the first sheet rows 9 through 408 are used for data but that range is divided into 25 sets of 16 rows. Each set corresponds to a column on the other sheet starting at column C. I would like the corresponding column to hide when the first row of each set (i.e. rows 9, 25, 41, etc.) are hidden.

View 3 Replies View Related

Hiding Columns Based On Criteria

Dec 7, 2006

I need to run this funtion from the starting column (N) to the last column ( dynamic).

Sub HideUnits()
Dim rngData As Range, rngHide As Range
Application. ScreenUpdating = False
With Sheet1
.Rows(1).Insert
.Range("B1").Value = "Temp"
Set rngData = .Range("N1:N" & .Cells(Rows.Count, "N").End(xlUp).Row)
rngData. AutoFilter field:=1, Criteria1:="*Units"
Set rngHide = rngData.SpecialCells(xlCellTypeVisible)
rngData.AutoFilter
rngHide.EntireRow.Hidden = True
.Rows(1).Delete
End With
Application.ScreenUpdating = True
End Sub

As you might be able to tell I need to hide all the columns with a specific word in the heading. I'm pretty sure I'd need to loop this somehow, but I'm not good with VBA.

View 3 Replies View Related

Error Hiding Multiple Columns In Vba

Oct 23, 2007

I am using an area of 43 Rows by ~ 150 Columns to display the results of an advancedfilter process. I have a trigger on row 44 for each column (which is either 1 or 0, depending on if any of the rows in the column were filled with data. If any column is completely empty I would like to hide it. I am getting an error if the majority of the ~ 150 columns are empty and should be hidden. Does anyone know if there is a maximum number of columns that can be hidden each time a macro is run?

My piece of code to accomplish this is as follows:

For i = 4 To 150
If Worksheets("RegMatrix"). Cells(44, i) = 1 Then
Worksheets("RegMatrix").Columns(i).AutoFit
Else
Worksheets("RegMatrix").Columns(i).ColumnWidth = 1
Worksheets("RegMatrix").Columns(i).Hidden = True
On Error Resume Next
End If
Next

Right now, once i gets to about 100 the rest of the columns are not hidden.

View 4 Replies View Related







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