Creating New sheets

mdkinsey

New Member
Joined
Jul 7, 2010
Messages
28
I have the following macro:

Sheets("3-13-11").Select
Sheets("3-13-11").Copy Before:=Sheets(1)
Sheets("3-13-11 (2)").Select
Sheets("3-13-11 (2)").Name = "3-20-11"
Rows("3:81").Select
Selection.EntireRow.Hidden = False
Range("B4:M81").Select
Selection.Replace What:="3-13-11", Replacement:="3-20-11", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="$13", Replacement:="$14", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Every week I have to create a new sheet with the same formulas and links as the previous one. Right now I go into the code and change the info I need to manually. How would I do this with out having to change the macro every week????
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi

You could use an Input Box to get the date and set a Date variable to pass the value given to the input box

George

I have the following macro:

Sheets("3-13-11").Select
Sheets("3-13-11").Copy Before:=Sheets(1)
Sheets("3-13-11 (2)").Select
Sheets("3-13-11 (2)").Name = "3-20-11"
Rows("3:81").Select
Selection.EntireRow.Hidden = False
Range("B4:M81").Select
Selection.Replace What:="3-13-11", Replacement:="3-20-11", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="$13", Replacement:="$14", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Every week I have to create a new sheet with the same formulas and links as the previous one. Right now I go into the code and change the info I need to manually. How would I do this with out having to change the macro every week????
 
Upvote 0
Try this to see the results

Sub sheetsname()

Dim answer As String

answer = InputBox("place your date here")

Sheets("sheet1").Name = answer

End Sub


I understand input box but I have little understanding of variables.
 
Upvote 0
Sorry forgot..

to a new workbook

Try this to see the results

Sub sheetsname()

Dim answer As String

answer = InputBox("place your date here")

Sheets("sheet1").Name = answer

End Sub
 
Upvote 0
Something like this:
Code:
Option Explicit

Sub NewFromTemplate()
Dim Date1 As Date
Dim Date2 As Date

Date1 = Application.InputBox("Enter date of sheet to duplicate from", "Source Sheet", "3-13-11", Type:=1)
If Date1 = 0 Then Exit Sub
Date2 = Application.InputBox("Enter date for new sheet", "New Sheet", Format(Date, "M-D-YY"), Type:=1)
If Date2 = 0 Then Exit Sub

Sheets(Format(Date1, "M-D-YY")).Copy Before:=Sheets(1)

With ActiveSheet
    .Name = Format(Date2, "M-D-YY")
    .Rows("3:81").Hidden = False
    .Range("B4:M81").Replace What:=Format(Date1, "M-D-YY"), _
        Replacement:=Format(Date2, "M-D-YY"), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    .Replace What:="$13", Replacement:="$14", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top