Save As Every Workbook and Limit the Rows to 200

PRIMA

Well-known Member
Joined
Oct 12, 2008
Messages
554
Dear All,

The code below is asking the file to select and save as, however, it will only save as once. In my case, I have 20,000 each worksheet and I want them to separately save as with different filename but it will only limit the rows to 200 each worksheet for every workbook or filename.

Say for Example:

The Header is in Row 1 & 2 = fixed

filename01
row 1+2 fix header
row 3 to 200 (from the original file)

filename02
row 1+2 fix header
row 201 to 398 (from the original file), but it should start from row 3

filename02
row 1+2 fix header
row 399 to 596 (from the original file), but it should start from row 3

until it will reach to the last row. Any ideas/suggestion please..

Code:
Sub SaveWB()
 
Dim strFile As String
Dim xlCalc As XlCalculation
Dim wb As Workbook, ws As Worksheet
Dim r As Range
With Application.FileDialog(msoFileDialogFilePicker)
    .Title = "Please select your file"
    .InitialFileName = Application.DefaultFilePath
    .AllowMultiSelect = False
    If .Show = -1 Then strFile = .SelectedItems(1) Else Exit Sub
End With
With Application
    xlCalc = .Calculation
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
End With
Set wb = Workbooks.Open(strFile, False)
For Each ws In wb.Worksheets
    With ws
        Set r = Application.Intersect(.Range("201:" & .Rows.Count), .UsedRange)
        If Not r Is Nothing Then r.EntireRow.Clear
        Set r = Nothing
    End With
Next ws
With Application.FileDialog(msoFileDialogSaveAs)
    .Title = "Please choose filename to save as"
    .AllowMultiSelect = False
    .InitialFileName = wb.FullName
    If .Show = -1 Then .Execute
End With
wb.Close
 
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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