Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Delete empty columns if not equal to .5 (Excel xp)

    I need to delete the blank columns from A to BB that the .columwidth is <> .5.

    Sub DeleteBlankCol()

    With ActiveSheet
    lLastColumn = .Range("AZ1").End(xlToRight).Column
    End With

    If ActiveCell.ColumnWidth <> 0.5 Then
    With ActiveSheet.Range("A1")
    For i = lLastColumn To 0 Step -1
    If Trim(.Offset(0, i) & .Offset(1, i)) = "" Then
    .Offset(0, i).EntireColumn.Delete
    End If
    Next i
    End With
    End If

    End Sub


    I don't have it right yet. Thank you for the help.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Delete empty columns if not equal to .5 (Excel xp)

    Do you want to delete the column if it is blank just in row 1, or if it's entirely blank?

    If the latter how about something like:

    Sub DeleteBlankCol()
    Dim C As Integer
    For C = 54 To 1 Step -1
    If Cells(1, C).ColumnWidth <> 0.5 Then ' I can only create column widths of 0.55 !?
    If Application.WorksheetFunction.CountBlank(Cells(1, C).EntireColumn) = _
    Application.Rows.Count Then Cells(1, C).EntireColumn.Delete Shift:=xlToLeft
    End If
    Next C
    End Sub
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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