Results 1 to 6 of 6

Thread: [RESOLVED] Can't delete blank columns

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,210

    Resolved [RESOLVED] Can't delete blank columns

    I have a worksheet with data in columns 'A' to 'BD' and rows 1 to 6776, however when I press ctrl+end I'm taken to ASD6776. In an attempt to get rid of all columns to the right of BD I
    1. Selected column BE
    2. Pressed ctrl+shift+the right-arrow key (which selects columns BE to XFD
    3. In the Immediate Window I entered selection.clear and pressed return
    4. I then went back to the sheet, right-clicked in the selection and chose Delete



    When I did ctrl+end again it still took me to ASD6776!

    How can I delete those unneeded columns?

  2. #2
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,871

    Re: Can't delete blank columns

    Did you check to see what value was in cell ASD6776? If there is a value there, including possibly characters characters that do not display, that might explain the issue.

    ActiveSheet.Cells("ASD6776") = ""

    Might clear that.

  3. #3

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,370

    Re: Can't delete blank columns

    the worksheet is still the same number of rows and columns regardless of what rows or columns you delete

    control end will always take you to the last column in the usedrange, deleting all values in used range will not change its size, but it appears, if you address the usedrange property of the worksheet it will reset the usedrange and give you the desired result

    try
    3. In the Immediate Window I entered selection.clear and pressed return
    activesheet.usedrange ' or a = activesheet.usedrange.address
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,560

    Re: [RESOLVED] Can't delete blank columns

    Yes, resolved.....

    Martin,
    i often have the same issue like you but for me it's mostly rows instead of columns.
    Deleting them apparantly doesn't solve the problem, but ......
    .... deleting them, and then explicitely saving the Workbook (optionally closing/reopening it) DOES work......
    Just look at the scrollbars while saving...... they jump from "infinite" to something making more sense.....
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

Posting Permissions

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



Click Here to Expand Forum to Full Width