VBA Macro in Excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmurphmsu
    New Member
    • Nov 2006
    • 19

    VBA Macro in Excel

    I am working on a VBA macro in Excel that will copy a sheet move it and then rename it based on what the user enters in a pop up box. Here is my code for the module:

    frmShow.Show

    Sheets("Jun 09 New").Select
    Sheets("Jun 09 New").Copy Before:=Sheets( frmShow.txtCopy Sheet.Text)
    Sheets("Jun 09 New (2)").Select
    Sheets("Jun 09 New (2)").Move After:=Sheets(f rmShow.txtCopyS heet.Text)
    Sheets("Jun 09 New (2)").Select
    Sheets("Jun 09 New (2)").Name = frmShow.txtNewS heet.Text
    Columns("I:I"). Select
    Selection.Copy
    Columns("H:H"). Select
    Selection.Inser t Shift:=xlToRigh t
    Columns("J:J"). Select
    Application.Cut CopyMode = False
    Selection.Clear Contents
    Range("J1").Sel ect
    Selection.Numbe rFormat = "@"
    Range("J1").Sel ect
    ActiveCell.Form ulaR1C1 = frmShow.txtNewS heet.Text
    Range("J2").Sel ect




    Where it has Sheets("Jun 09 New") is there a way to put the text property of a text box like I have on this line of code Sheets("Jun 09 New").Copy Before:=Sheets( frmShow.txtCopy Sheet.Text). It works as is, but I want to be able to have the user select a sheet to copy, then place it after that and name it the Name they put in the text box.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by mmurphmsu
    I am working on a VBA macro in Excel that will copy a sheet move it and then rename it based on what the user enters in a pop up box. Here is my code for the module:

    Code:
    frmShow.Show
        
        Sheets("Jun 09 New").Select
        Sheets("Jun 09 New").Copy Before:=Sheets(frmShow.txtCopySheet.Text)
        Sheets("Jun 09 New (2)").Select
        Sheets("Jun 09 New (2)").Move After:=Sheets(frmShow.txtCopySheet.Text)
        Sheets("Jun 09 New (2)").Select
        Sheets("Jun 09 New (2)").Name = frmShow.txtNewSheet.Text
        Columns("I:I").Select
        Selection.Copy
        Columns("H:H").Select
        Selection.Insert Shift:=xlToRight
        Columns("J:J").Select
        Application.CutCopyMode = False
        Selection.ClearContents
        Range("J1").Select
        Selection.NumberFormat = "@"
        Range("J1").Select
        ActiveCell.FormulaR1C1 = frmShow.txtNewSheet.Text
        Range("J2").Select
    Where it has Sheets("Jun 09 New") is there a way to put the text property of a text box like I have on this line of code Sheets("Jun 09 New").Copy Before:=Sheets( frmShow.txtCopy Sheet.Text). It works as is, but I want to be able to have the user select a sheet to copy, then place it after that and name it the Name they put in the text box.
    Looks like nice work partner, I'll send over to VBA for added input for ya... Hope you get what you're looking for.

    Good luck!

    Comment

    Working...