+ Reply to Thread
Results 1 to 11 of 11

Autofitting Columns

  1. #1
    Registered User
    Join Date
    08-20-2008
    Location
    DFW, Texas
    Posts
    26

    Autofitting Columns

    I've adjusted how I export a sheet. I'll attach the code below. I'm trying to then get the area to autofit the columns, but it doesn't seem to be working. Please let me know if you can see something wrong in the coding.

    Please Login or Register  to view this content.
    Last edited by dominicb; 09-03-2008 at 10:34 AM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Please Login or Register  to view this content.
    '

    You don't want a '

    get rid of the '

    then it will work

    HTH

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon SQChevy
    Quote Originally Posted by SQChevy View Post
    I'm trying to then get the area to autofit the columns, but it doesn't seem to be working. Please let me know if you can see something wrong in the coding.
    Next time you post code please remember to wrap it using the code tags ("#" button in the toolbar above the editor window) - I've done it for you this time.

    You seem to have commented out the "Autfit" line - does it work if this line is uncommented?

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    You seem to have commented out the "Autfit" line - does it work if this line is uncommented?
    No points for creativeness of answer

    Creativeness is a word

  5. #5
    Registered User
    Join Date
    08-20-2008
    Location
    DFW, Texas
    Posts
    26
    THank you I was trying to figure out how to do that.

    I sorry even with the code not a comment it wasn't working. I was moving things around to see if it was the location in the code affecting it. It wasn't working with the ' removed.

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Fair enough, what do you mean by not work? Doesn't shrink enough? Doesn't grow enough?

    If it doesn't move at all, have you tried, whilst stepping through the code, resizing the columns manually just before the autofit to see what happens then?

    Are you sure there are not hidden strings somewhere whcih make the columns not a size you'd like.

  7. #7
    Registered User
    Join Date
    08-20-2008
    Location
    DFW, Texas
    Posts
    26
    It doesn't seem to move at all. It should expand to allow for the longer text. I will try moving them before the autofit code. (It didn't work) I got the coding for doing this step by recording the macro so it astounds me that it doesn't work. Do you think it has something to do with the screen updating? There shouldn't be any columns like that. There are a few hidden rows, but they shouldn't cause the columns to not autofit. If I then go it and double click the column boundary it autofits properly.

  8. #8
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    one idea:
    Have a look at the text wrap property of the cells.
    (Ctrl + 1) on the cells you'd expect to be good to you. Text wrap enabled could cause this...

    re: screenupdating - no, I wouldn't have thought that could make the difference

    You could also try defining the sheet where the columns are explicitly. i.e.:
    Please Login or Register  to view this content.
    This is generally better practice, most of your select and activate statements are unnecessary.

    HTH

  9. #9
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Maybe post an attachment if you're still stuck?

  10. #10
    Registered User
    Join Date
    08-20-2008
    Location
    DFW, Texas
    Posts
    26
    Cheeky...Thank you. Specifying the sheet is what did it. I had tried to do that by adding the activate on sheet 1, but I guess it didn't do what I was expecting.

  11. #11
    Registered User
    Join Date
    08-20-2008
    Location
    DFW, Texas
    Posts
    26
    One more question: is there a way to automate the deleting of the other sheets. It still asks if you want to delete. Since I'm moving to an empty worksheet, I just want the single sheet. We will usually be moving the sheet to another spreadsheet.

    Any suggestions on how to add to an existing workbook? If it's open or not. Or is that another complicated beast all of it's own.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sorting and copying columns (Forms)
    By DanSherwood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-17-2009, 01:11 PM
  2. hiding / showing columns...
    By LSB M in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-07-2008, 05:50 PM
  3. Hide and Unhiding Columns
    By papastyle3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2008, 11:03 AM
  4. Hiding/Unhiding columns based on a dropdown list
    By jim_0068 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2007, 11:57 AM
  5. SUM array with multiple columns
    By carsto in forum Excel General
    Replies: 1
    Last Post: 10-31-2006, 03:13 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1