PDA

View Full Version : Hidding a column



makako
08-04-2006, 06:19 AM
I have an organized worksheet that have an ID in the 2nd row, it can be either D for date, $ for Currency values, etc. I created a macro that makes invisible every column except the ID of once choice. The worksheet has no shapes, images etc but when running it an error pops telling me some objects cannot be displaced outside the worksheet. What con I do? Thanks

LitVilkas
08-04-2006, 07:11 AM
Post your Code

makako
08-04-2006, 09:44 AM
Sub SubColumnasMostrarSoloFechas()
Dim lvCont As Integer
Sheets("InfoVis").Cells.EntireColumn.Hidden = False
For lvContador = 0 To Range("Names").CurrentRegion.Cells.Count - 1
If Not IsError(Range("Names").Offset(2, lvContador).Value) Then
If Range("Names").Offset(2, lvContador).Value <> "D" Then
Range("Name").Offset(, lvContador).EntireColumn.Hidden = True
End If
Else
Range("Names").Offset(, lvContador).EntireColumn.Hidden = True
End If
Next
End Sub

The reason for using the ISERROR sentence is because there are some formulas that I copy in cells below but when being calculated in this specific row it shows an error

Edited 7-Aug-06 by geekgirlau. Reason: insert vba tags

LitVilkas
08-06-2006, 11:40 PM
I'm afraid you'll have to attach the entire file for someone else to understand what you're doing.

2 comments so far: are you sure that 'CurrentRegion.Cells.Count' is what you want to use? It depends on your sheet, but can easily return a result larger than 255, the number of columns in Excel. Then you might get an error referring o something outside the worksheet. Better try
[columnnumbers = Sheets("InfoVis").UsedRange.Columns.Count]
Also, in you 7th line of code (Range("Name").Offset(, lvContador).EntireColumn.Hidden = True) I assume you should replace "Name" with "Names", in line with your other statements.

asingh
08-07-2006, 02:51 AM
Are you trying to HIDE areas which are "MERGED"....???

makako
08-07-2006, 04:59 PM
I tried to post the archive but zipped is larger than the permited quota. There are no merged cells, recently I tried to enlarge a column to its maximum width (255) and I then was able to hide the rest of them