Results 1 to 11 of 11

Autofitting Columns

Threaded View

  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.

    Private Sub CommandButton1_Click()
      Dim NewName As String
      Dim nm As Name
      Dim ws As Worksheet
      Dim obj As Shape
      Dim sSheet As Object
      Dim strname As String
      
      With Application
        .ScreenUpdating = False
    
        NewName = InputBox("Please specify the name of the new workbook", "New Copy")
    
        Range("A1:B57").Select
        Selection.Copy
        Workbooks.Add
        ActiveSheet.Paste
    
        Sheets(Array("Sheet2", "Sheet3")).Select
        Sheets("Sheet3").Activate
        Application.CutCopyMode = False
        ActiveWindow.SelectedSheets.Delete
        Sheets("Sheet1").Activate
        ActiveWindow.Zoom = 70
        
        'Columns("A:B").EntireColumn.AutoFit
    
        ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & ".xls"
        ActiveWorkbook.Close SaveChanges:=False
        .ScreenUpdating = True
      End With
    End Sub
    Last edited by dominicb; 09-03-2008 at 10:34 AM.

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