+ Reply to Thread
Results 1 to 3 of 3

Splitting one worksheet into multiple sheets within the same workbook based on row number

  1. #1
    Registered User
    Join Date
    02-05-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    2

    Splitting one worksheet into multiple sheets within the same workbook based on row number

    Hi All,

    I have been trying to do a VBA code to split one excel sheet into multiple sheets within a workbook. Lets say, I have a sheet with data on 100 different parameters. I would like to seperate that excel sheet into multiple sheets - one sheet for each parameter. The sheet is to be split after every 70th row. I tried the below code (I'm not a expert, just have basic understanding of VBA coding). However, it is always throwing a type mismatch error or some othe error.

    Sub test()

    Dim lastRow As Long, myRow As Long, myBook As Sheets
    lastRow = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
    For myRow = 2 To lastRow Step 69 ----------------------------------------------------"Every 70th row the sheet is to be split and copied to a new sheet"

    Set myBook = ThisWorkbook.Sheets.Add ----------------------" Adding new sheet in the same workbook"

    ThisWorkbook.Sheets("Sheet1").Rows(myRow & ":" & myRow + 69).EntireRow.Copy myBook("A1") -------------- "copying to new sheet"

    Next myRow

    End Sub


    Could anyone help me with this.

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Splitting one worksheet into multiple sheets within the same workbook based on row num

    I modified your code, try this way:
    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Registered User
    Join Date
    02-05-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    2

    Re: Splitting one worksheet into multiple sheets within the same workbook based on row num

    Thanks a lot. It worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. splitting multiple worksheet based on column criteria
    By sachin483 in forum Excel General
    Replies: 2
    Last Post: 04-10-2015, 10:27 PM
  2. [SOLVED] Splitting Excel sheet into multiple sheets based on random values of a column.
    By Preeti1309 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 04-22-2014, 11:07 PM
  3. [SOLVED] Copy Template Worksheet to Multiple Worksheets and Incrementally Number Sheets in Workbook
    By dingbat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-25-2014, 01:18 PM
  4. [SOLVED] Splitting Master Sheet Based on Different Columns Into Multiple Sheets
    By LISSANN in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2013, 06:22 PM
  5. splitting excel workbook into seperate sheets depending on number of rows
    By buketdurusoy in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-28-2012, 04:52 PM
  6. Create multiple sheets in new workbook based on credentials in source workbook
    By Julesdude in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-07-2011, 10:31 AM
  7. Replies: 0
    Last Post: 03-01-2005, 05:05 PM

Tags for this Thread

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