Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 01-30-2019, 03:28 PM
NoSparks NoSparks is offline Macro to create two copies of worksheet, then run macro. Windows 7 64bit Macro to create two copies of worksheet, then run macro. Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Perhaps something like this using variables to refer to the worksheets.
When you make a copy of a sheet, the copy automatically becomes the active sheet.
Code:
Sub ThreeWaySplit()

    Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
    Dim arr As Variant

'create copies, rename sheets
    'original sheet
    Set ws1 = ActiveSheet
    'break apart the original sheet name into an array
    arr = Split(ws1.Name, "_")
    'rename original
    ws1.Name = arr(2) & "_260"
    'first copy
    ws1.Copy After:=Sheets(1)
    ActiveSheet.Name = arr(2) & "_350"
    Set ws2 = ActiveSheet
    'second copy
    ws1.Copy After:=Sheets(2)
    ActiveSheet.Name = arr(2) & "_450"
    Set ws3 = ActiveSheet
    
'deal with original sheet
    With ws1
        .Select
        Application.Run "PERSONAL.XLS!Survey40wire"
        Application.Run "PERSONAL.XLS!Survey20WireShrinkRunFirst"
        Application.Run "PERSONAL.XLS!Survey20WirePortaitRunSecond"
    End With
'deal with first copy
    With ws2
        .Select
        Application.Run "PERSONAL.XLS!Survey40wire"
        Application.Run "PERSONAL.XLS!Survey20WireShrinkRunFirst"
        Application.Run "PERSONAL.XLS!Survey20WirePortaitRunSecond"
    End With
'deal with second copy
    With ws3
        .Select
        Application.Run "PERSONAL.XLS!Survey40wire"
        Application.Run "PERSONAL.XLS!Survey20WireShrinkRunFirst"
        Application.Run "PERSONAL.XLS!Survey20WirePortaitRunSecond"
    End With
    
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to create two copies of worksheet, then run macro. Macro to print a value in the duplicate and triplicate copies only Marcia Excel Programming 2 09-26-2018 02:11 PM
Macro for printing 2 copies each on NCR paper for many different word docs Marq Word VBA 9 05-22-2017 08:31 PM
Looking for Help to Create a Macro (Sort) rsrasc Word VBA 5 04-16-2014 03:25 AM
Macro to conditionally create or go to worksheet Reinaldo123 Excel Programming 1 07-06-2012 07:23 AM
macro for comparing data from 3 columns and pasting into another worksheet ashukla Excel 1 06-24-2009 05:01 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft