Consulting

Results 1 to 6 of 6

Thread: Hidding a column

  1. #1
    VBAX Contributor
    Joined
    Aug 2006
    Posts
    120
    Location

    Hidding a column

    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

  2. #2
    Post your Code

  3. #3
    VBAX Contributor
    Joined
    Aug 2006
    Posts
    120
    Location
    [vba]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
    [/vba]
    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

  4. #4
    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.

  5. #5
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Are you trying to HIDE areas which are "MERGED"....???

  6. #6
    VBAX Contributor
    Joined
    Aug 2006
    Posts
    120
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •