简体   繁体   中英

create a new sheet by using macro in excel 2007

I am just a new beginer and want to create a new spreatsheet by using Macro. i have the code like these.My code did copy the Blank From but the new sheet's width and heigh are different from the origianl one(Blankform) and i want

  1. lock the column B6--down and Column I6--down.

  2. is it possible i can create a pop window and ask the name of the new sheet and name the new spreadsheet.

It should be simple for most of people here but for me i really hard. So please help.

thanks

Sub CreateNewSheet()

Sheets("Blank form").Select
ActiveWorkbook.Sheets.Add after:=ActiveSheet
Sheets("Blank form").Range("a1:f281").Copy
Range("a1").Select
ActiveSheet.Paste
Range("a1").Select
Application.CutCopyMode = False
Sheets("Blank form").Select
Range("a1").Select
End Sub

Try this

Sub CreateNewSheet()
dim sName as string
Sheets("Blank form").copy after:=activesheet

sname=inputbox("Enter new sheet name")
on error resume next
activesheet.name=sname
if err<>0 then msgbox "Name not valid"
err.clear
on error goto 0

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM