+ Reply to Thread
Results 1 to 9 of 9

Open Workbooks and Adjust Column Width, Save, and Close VBA

  1. #1
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Open Workbooks and Adjust Column Width, Save, and Close VBA

    Hi guys, looking to to get my macro working that opens up about 20 workbooks in a specific folder and adjusts columns widths then saves&closes. One at a time, so I just ran a loop but have hit a roadblock.
    Please Login or Register  to view this content.
    Thanks,

  2. #2
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    417

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Try changing
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  4. #4
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Greg, better and faster, thanks!
    If I alter: Constraint
    Please Login or Register  to view this content.
    into
    Please Login or Register  to view this content.
    Can I pick specific columns instead of a range?

    Thanks again

  5. #5
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Also, why won't it work entering widths with a decimal:
    Please Login or Register  to view this content.
    Thanks,

  6. #6
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    417

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    6.86 is not an Integer - you need to declare it as a Single or Double.

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Hi again,

    Many thanks for your feedback.

    The following code should do what you need. The changes from the earlier version have been highlighted:


    Please Login or Register  to view this content.
    Hope this helps - please let me know how you get on.

    Regards,

    Greg M


    P. S. Many thanks also for the Reputation increase - much appreciated
    Last edited by Greg M; 11-24-2015 at 06:55 PM. Reason: P. S. added

  8. #8
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,467

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Hi again,

    Many thanks for the Reputation increase - much appreciated

    Glad I was able to help.

    Best regards,

    Greg M

  9. #9
    Forum Contributor
    Join Date
    08-23-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 365
    Posts
    166

    Re: Open Workbooks and Adjust Column Width, Save, and Close VBA

    Thanks for the help Greg

+ 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. Need macro to open, refresh, save, close 50 workbooks in a folder.
    By paulcg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 09:23 AM
  2. Macro to close all open workbooks save two not working
    By drajanm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2011, 05:58 AM
  3. [SOLVED] how to adjust the width of a cell and not the entire column
    By gabrie ruz in forum Excel General
    Replies: 3
    Last Post: 08-03-2006, 01:00 PM
  4. [SOLVED] Adjust column width
    By tlee in forum Excel General
    Replies: 2
    Last Post: 05-04-2006, 07:00 PM
  5. Auto Adjust the Width of a Column
    By reddog9069 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 12:10 PM
  6. Adjust Column Width?
    By CDAK in forum Excel General
    Replies: 0
    Last Post: 06-16-2005, 06:05 PM
  7. [SOLVED] adjust column width
    By coolbeans in forum Excel General
    Replies: 1
    Last Post: 05-15-2005, 08:06 AM
  8. [SOLVED] Using Code to Adjust Specific Column Width
    By Nigel Bennett in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2005, 03:06 AM

Tags for this Thread

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