Quick lil Macro

cav~firez22

Well-known Member
Joined
Jun 21, 2006
Messages
543
Could someone help me with a quick little macro...?

Im trying to get something to do the following

copy the active sheet to the end of the workbook.
rename that copy to the value of cell B2


Think someone could help with this??
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Code:
Sub Macro1()
    x = ActiveSheet.Range("b2").Value
    ActiveSheet.Copy after:=Sheets(Sheets.Count)
    ActiveSheet.Name = x
End Sub
 
Upvote 0
wOW, talk about quick. Thank.

how about a few more parts of it??

Im stuck trying to get a range created from the sheet names.

Each time the sheet is copied, and the name is applied from the value of the cell.... Im trying to get it to copy the name of the sheet to Cell A40, on sheet Template. and then as more sheets get created, to keep filling in the sheet names in the first empy cell below A40 on sheet template..


sounds hard, seems hard, as im stuck... :)

thanks
 
Upvote 0
Code:
Sub Macro1() 
    LR = Sheets("template").Cells(Rows.Count,"A").End(xlup).Row + 1
    x = ActiveSheet.Range("b2").Value 
    ActiveSheet.Copy after:=Sheets(Sheets.Count) 
    ActiveSheet.Name = x 
    Sheets("template").Range("A" & LR).Value = x
End Sub
 
Upvote 0
Ok, one more question... i think

Code:
Cells.Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= False

How can i get this to Password the protection, as i dont want the user to know the password.

Thanx much
 
Upvote 0
Code:
With ActiveSheet
   .Cells.Locked = True
   .Cells.FormulaHidden = False
   .Protect "Password", DrawingObjects:=False, Contents:=True, Scenarios:=False
End With

You will need to include the password in any code you have that UNprotects the sheet..

.Unprotect "Password"
 
Upvote 0
for
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False


How would i make it copy all the formats and such as well? currently its just the values.
 
Upvote 0
With 2 lines, one for the values, then one for the formats..
Code:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
 
Upvote 0

Forum statistics

Threads
1,222,246
Messages
6,164,797
Members
451,917
Latest member
WEB78

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