Hi
I have code that I've reused from another macro. I'm copying information from one tab, creating a new workbook, pasting in there, saving that new workbook and closing.
Within the course of the code, I also ensure that I autofit the rows so we can see all the text.
When I "watch" the code run, the autofit works. However, when the new Workbook saves and closes, the lines resize smaller?? This doesn't happen in the original code.. I run it and it works fine, the autofit stays.
I've tried placing the autofit code at different places.. nothing helps...
Hope you have some ideas!
Sub QuoteFollowUpTab_FILE()
' creates report to be sent for follow-up
'
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
'sets Dims for filesaveas
Dim fname As Variant
Dim NewWb As Workbook
Dim FileFormatValue As Long
'these are to delete rows with 0 for UW copy
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
fname = Application.GetSaveAsFilename(InitialFileName:=Sheets("Quote Follow-Up Tab - FILE").Range("A1").Value, _
filefilter:="Excel Files (*.xls), *.xls", _
Title:="Choose Folder to Save Reports")
If fname <> False Then
'Copy the ActiveSheets ("Follow-Up Tab - FILE")to new workbook
Sheets("Quote Follow-Up Tab - FILE").Rows("9:106").Select
Selection.Rows.Autofit
Sheets("Quote Follow-Up Tab - FILE").Select
Sheets("Quote Follow-Up Tab - FILE").Copy
Cells.Select 'selects all cells on tab
Selection.Copy 'copies them
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False 'paste special values into new tab
Set NewWb = ActiveWorkbook 'puts them into the new workbook and sets its Dim as "NewWb"
ActiveSheet.Shapes("Button 6").Select
Selection.Cut 'delete button
Rows("9:106").Select
Selection.Rows.Autofit
ActiveCell.Select
'set values for row dims for deleting
Firstrow = 9
Lastrow = 106
'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1
'We check the values in the A column in this example
With ActiveSheet.Cells(Lrow, "A")
If Not IsError(.Value) Then
If .Value = "0" Then .EntireRow.Delete
'This will delete each row with the Value "0"
'in Column A, case sensitive.
ElseIf .Value = "1" Then .EntireRow.Autofit
'This will autofit each row with the Value "1"
'in Column A, case sensitive.
End If
End With
Next Lrow
Sheets("Quote Follow-Up Tab - FILE").Range("A3").Select
'saves new workbook with the file name we created and saved in Dim fname
NewWb.SaveAs fname, CreateBackup:=False
ActiveSheet.Range("C3").Select
NewWb.Close False 'This closes the new workbook
Set NewWb = Nothing
End If
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
Range("C3").Select
End Sub
Bookmarks