Results 1 to 29 of 29

Move data & duplicate current sheet

Threaded View

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 97
    Posts
    49

    Move data & duplicate current sheet

    Hello there and thank you very much for any help received in advance. I have only recently started to learn VBA and have been putting it to practice in creating userforms to help people at my work to be able to timetable more quickly.

    I have realised however that in many cases the basic code that I have been using could often be improved. However in the sections below I have not been able to work this out for myself. This needs to be done as after a large number of worksheets exists excel gradually gets slower and slower when running the macros.

    Please could anyone help?

    Macro 1

    Private Sub CommandButton1_Click()
        oldSheet = ActiveSheet.Name
        Sheets("Schedule A GE2").Select
            Range("D5").Select
            ActiveCell.FormulaR1C1 = "='Teacher Class & Room List'!R[-3]C[-3]"
            Range("D6").Select
        Sheets("Schedule B GE2").Select
            Range("D5").Select
            ActiveCell.FormulaR1C1 = "='Teacher Class & Room List'!R[-3]C[-3]"
            Range("D6").Select
        Sheets("Schedule A GE1").Select
            Range("D5").Select
            ActiveCell.FormulaR1C1 = "='Teacher Class & Room List'!R[-3]C[-3]"
            Range("D6").Select
        Sheets("Schedule B GE1").Select
            Range("D5").Select
            ActiveCell.FormulaR1C1 = "='Teacher Class & Room List'!R[-3]C[-3]"
            Range("D6").Select
        Sheets(oldSheet).Activate
    End Sub
    Macro 2

    Private Sub CreateButton_Click()
    
    NewSheet = NameBox.Text
    SillyThing = "Name: "
        ActiveSheet.Copy after:=Sheets(Sheets.Count)
        Sheets(Sheets.Count).Name = NewSheet
        Range(" A5").Value = SillyThing & NameBox.Text
    
    End Sub


    The second of the two macros is the real issue as due to how excel apparently names worksheets the macro will stop working after some time and the only way I have worked out to get it working again is to save and re-open the workbook. It also takes some time to run as I am a complete noob with the dim function.

    Many thanks,

    Tom
    Last edited by TBrooker; 07-14-2009 at 07:16 AM.

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