issue with splitting a large excel file into files of 100 rows. Also keeping leading Zero in zip code column

spudn56

New Member
Joined
May 6, 2020
Messages
7
Office Version
  1. 2019
Platform
  1. MacOS
issue with splitting a large excel file into files of 100 rows per file. I have attached a picture of the file I had tried an app but it also removes the leading zero in the zip code field even though I formated the cell named zip code with special-zip. I didn't know how to attach the file here sorry.
 

Attachments

  • FCBD471C-B3A1-4B37-9791-551D90F86C21.jpeg
    FCBD471C-B3A1-4B37-9791-551D90F86C21.jpeg
    248.5 KB · Views: 3

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You might be able to work out something from this. It works OK on my PC with xl2013. New files are named according to first row of the group.

VBA Code:
Sub t()
Dim i As Long
    With ActiveSheet
       For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row Step 100
            Workbooks.Add
            .Rows(i).Resize(100).Copy
            ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial xlPasteValuesAndNumberFormats
            ActiveWorkbook.SaveAs "Split " & i & ".xlsx", FileFormat:=51
            ActiveWorkbook.Close False
        Next
    End With
End Sub
 
Upvote 0
You might be able to work out something from this. It works OK on my PC with xl2013. New files are named according to first row of the group.

VBA Code:
Sub t()
Dim i As Long
    With ActiveSheet
       For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row Step 100
            Workbooks.Add
            .Rows(i).Resize(100).Copy
            ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial xlPasteValuesAndNumberFormats
            ActiveWorkbook.SaveAs "Split " & i & ".xlsx", FileFormat:=51
            ActiveWorkbook.Close False
        Next
    End With
End Sub
Worked GREAT THANK YOU SO MUCH!
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,381
Members
448,888
Latest member
Arle8907

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