+ Reply to Thread
Results 1 to 5 of 5

Copy Marcro with Worksheet

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    07-16-2007
    Location
    GA
    MS-Off Ver
    Office 365 - Version 2403
    Posts
    1,059

    Question Copy Marcro with Worksheet

    Hi Excel Users,

    I have a task log worksheet & each week a copy & create a new one. The template is the same & each worksheet is labeled FW 1, FW 2, etc.

    My macro doesn't seem to copy over when I change the worksheet name. How can I edit or create a new macro that will recognize & then change with the worksheet name?


    Thanks
    MyCon
    -- Using Latest Version of Excel

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Copy Marcro with Worksheet

    Do you mean you make a copy of a worksheet in the same workbook?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Copy Marcro with Worksheet

    You should post your code for us to see. Use code tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Copy Marcro with Worksheet

    Not sure if this is helpful, but FWIW,

        Dim i As Long
        
        i = Sheets.Count
        
        Worksheets("Sheet1").Copy after:=Sheets(i)
        
        i = Sheets.Count
        Worksheets("Sheet1 (2)").Name = "FW" & i - 1
    Where "Sheet1" is the name of the task log sheet.
    The code copies this sheet, counts the number of sheets, offsets the count by -1 and renames the new sheet to "FW" and the sheet count.

    Is this helpful?
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  5. #5
    Valued Forum Contributor
    Join Date
    07-16-2007
    Location
    GA
    MS-Off Ver
    Office 365 - Version 2403
    Posts
    1,059

    Re: Copy Marcro with Worksheet

    Hi,

    Yes, I created a template in a Worksheet, then copy the whole worksheet, which carries over all my data, including the marcro.

    Other than changing the worksheet name from FW 1 to FW 2, everything else is pretty much the same.


    This seemed to work well with Excel 2003, but not so much in 2007.

    I'll try the code that Palmetto just gave.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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