+ Reply to Thread
Results 1 to 4 of 4

macro revision help -> creating separate tabs

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,225

    macro revision help -> creating separate tabs

    Hi all

    I have a macro on a file that copies data and creates separate tabs from "master" using "template" as the basis.

    Sub CreateSheets()
        Dim ms      As Worksheet
        Dim ws      As Worksheet
        Dim sh      As Worksheet
        Dim cell    As Range
        Dim rng     As Range
        Dim oRange  As Range
    
        Application.ScreenUpdating = False
            Set ms = ThisWorkbook.Sheets("Master")
            Set ws = ThisWorkbook.Sheets("Template")
            Set rng = ms.Range("A5:A" & ms.Cells(Rows.Count, 1).End(xlUp).Row)
        
            For Each sh In ThisWorkbook.Worksheets
                If sh.Name <> ms.Name And sh.Name <> "Template" Then
                    Application.DisplayAlerts = False
                        sh.Delete
                    Application.DisplayAlerts = True
                End If
            Next sh
        
            For Each cell In rng
                If cell.Value = "" Then
                    If oRange Is Nothing Then Set oRange = cell Else Set oRange = Union(oRange, cell)
                End If
            Next cell
            If Not oRange Is Nothing Then oRange.ClearContents
        
            For Each cell In rng.SpecialCells(2).Areas
                ws.Copy After:=ThisWorkbook.Sheets(Sheets.Count)
        
                ActiveSheet.Name = ms.Range(Split(cell.Columns(3).Offset(1).Address, ":")(1)).Value
                cell.Resize(cell.Rows.Count + 1, cell.Columns.Count + 9).Copy
                ActiveSheet.Range("A5").PasteSpecial xlPasteAll
                Application.Goto ActiveSheet.Range("A1")
    
            Next cell
        
            Application.CutCopyMode = False
        Application.ScreenUpdating = True
    End Sub

    it seems to be working fine, however, it messes on this line:

    ActiveSheet.Name = ms.Range(Split(cell.Columns(3).Offset(1).Address, ":")(1)).Value
    it seems to create all tabs from master except for row 74 --> could it be bc column C value is listed only once?

    thxs
    Attached Files Attached Files
    Last edited by jw01; 04-24-2019 at 02:04 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: macro revision help -> creating separate tabs

    could it be bc column C value is listed only once?
    Yup, try this instead
                ActiveSheet.Name = cell.Offset(, 2).Resize(1, 1).Value

  3. #3
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,225

    Re: macro revision help -> creating separate tabs

    great thxs

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: macro revision help -> creating separate tabs

    You're welcome & thanks for the feedback

+ 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. [SOLVED] Macro to convert tabs into separate excel files
    By jharvey87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2017, 12:56 PM
  2. Macro help: Separating data into tabs and creating a table of content of those tabs
    By AntiPivotTable in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-15-2015, 11:57 AM
  3. Moving multiple excel tabs into separate tabs/separate files
    By RO24 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-02-2014, 11:04 AM
  4. VBA to Save each BOM revision in separate hidden Worksheet and more...
    By Coval in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-10-2014, 11:41 PM
  5. [SOLVED] Using Macro to separate a spreadsheet and create tabs for each month
    By ajang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 01:42 AM
  6. [SOLVED] Creating a Macro to calculate the # of parts and to exclude the revision #s at the end.
    By legeorgia in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-08-2012, 05:13 PM
  7. Macro to separate data into tabs
    By tso6359 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2011, 07:46 PM

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