Macro to: Create New Sheet, Copy and Paste Into New Sheet
Hi,
I'm new to VBA (excel 2011) and working on an "auto-mated" spread sheet for my boss. My boss knows less about excel than I do, so I'm trying to make it as hands off as possible. To this end, I've been working on macros so she just has to push one button for the desired results. I have two needs,
The macro in mind:
I want to have it:
create a new sheet
name the sheet based on Cell Name (A1)
copy cells A1:Q211
Paste them into New Sheet
Another thing I need is a macro to make a summary sheet of all sheets past the summary sheet. I know theres a macro template already out there, but the link to that site appears to be broken. Any help in getting started on that would be great.
Re: Macro to: Create New Sheet, Copy and Paste Into New Sheet
I was able to find a solution/macro to my problem. Thanks for your work guys!
PHP Code:
Sub Add()
Dim wsName As Variant, wsInvalid As String Dim ws As Worksheet, wsArray As Variant, i As Integer wsArray = Array("[", "]", "/", "\", "?", ":") GetName: wsName = Application.InputBox("Please enter the day's date." & vbCrLf & wsInvalid, , , , , , , 2) If wsName = False Or wsName = vbNullString Then Exit Sub
For i = LBound(wsArray) To UBound(wsArray) wsName = Replace(wsName, wsArray(i), "") Next If Len(wsName) > 31 Then wsName = Left(wsName, 31)
On Error Resume Next Set ws = Sheets(wsName) On Error GoTo 0
If Not ws Is Nothing Then Set ws = Nothing wsInvalid = "The worksheet " & wsName & " already exists!" GoTo GetName Else Sheets("Update Sheet").Copy after:=Sheets(ActiveSheet.Name) ActiveSheet.Name = wsName End If
Bookmarks