SaveAs isn't saving all the Columns in Worksheet

gedmead

New Member
Joined
Aug 3, 2014
Messages
2
I have a workbook with several worksheets. The sheet I want to save has data and/or cell formatting across the range A1 to LP46.

I'm using this VBA code from a button within the worksheet to save the same worksheet:


Code:
    '  Copy just the current sheet
   ActiveSheet.Select
   ActiveSheet.Copy
   
    ' Save the new file
    '  Create variable for file name
    Dim SavedFileName As String
     SavedFileName = Range("B2").Value & " - Consolidated RMA " & Range("R2").Value & "++ " & " GTI.xls"
   
   '  Save it
    ActiveSheet.SaveAs "C:\SERVICES\" & SavedFileName, FileFormat:=56


    '  Close the newly created file
   ActiveWorkbook.Close False
          
       '  Return user to ConsGTISheet
    Windows("WorkshopInput.xlsm").Activate
    Sheets("Consolidated GTI").Select
       
   
    MsgBox ("Worksheet saved :" & SavedFileName & vbCrLf & "")

When I check it, the saved file only contains columns A to IV!

Is there some limitation in Excel that causes the selection to be truncated like this?

I see that it does save all the empty rows below Row 46. So I'm wondering if there's an alternative version I should use that just saves the range A1:LP46 to a new file? If so, can someone please help with the code needed?

Thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Your saving in FileFormat 56 which is Excel 97 - 2003 format which is limited to 256 columns use 51 if it is a macro free workbook or 52 if you want to keep the macro.

Code:
     SavedFileName = Range("B2").Value & " - Consolidated RMA " & Range("R2").Value & "++ " & " GTI.xls[COLOR="#FF0000"]x[/COLOR]"
   
   '  Save it
    ActiveSheet.SaveAs "C:\SERVICES\" & SavedFileName, FileFormat:=[COLOR="#FF0000"]51[/COLOR]

or
Code:
     SavedFileName = Range("B2").Value & " - Consolidated RMA " & Range("R2").Value & "++ " & " GTI.xls[COLOR="#FF0000"]m[/COLOR]"
   
   '  Save it
    ActiveSheet.SaveAs "C:\SERVICES\" & SavedFileName, FileFormat:=[COLOR="#FF0000"]52[/COLOR]
 
Upvote 0
Your saving in FileFormat 56 which is Excel 97 - 2003 format which is limited to 256 columns use 51 if it is a macro free workbook or 52 if you want to keep the macro.

Code:
     SavedFileName = Range("B2").Value & " - Consolidated RMA " & Range("R2").Value & "++ " & " GTI.xls[COLOR=#FF0000]x[/COLOR]"
   
   '  Save it
    ActiveSheet.SaveAs "C:\SERVICES\" & SavedFileName, FileFormat:=[COLOR=#FF0000]51[/COLOR]

or
Code:
     SavedFileName = Range("B2").Value & " - Consolidated RMA " & Range("R2").Value & "++ " & " GTI.xls[COLOR=#FF0000]m[/COLOR]"
   
   '  Save it
    ActiveSheet.SaveAs "C:\SERVICES\" & SavedFileName, FileFormat:=[COLOR=#FF0000]52[/COLOR]

Thank you so much - that fixed it! :)
 
Upvote 0

Forum statistics

Threads
1,215,359
Messages
6,124,488
Members
449,165
Latest member
ChipDude83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top