Forum Discussion
mtschroe
Oct 01, 2021Copper Contributor
How to create a new sheet with a name based on a cell? (Macro)
Hi All, Trying to record a macro that will automatically refresh a report. Because of the size of the dataset/number of formulas, each time the report is run I make a hard copy / hide the formul...
mtschroe
Oct 01, 2021Copper Contributor
THanks so much for the fast response Hans!
I did try this, however ran into a "1004 Error: Application-defined or Object-defined error"
Any idea what might be causing this? When I click the debugger the last line is highlighted.
Here is a snippet of the later part of the code:
Range("A5:B5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Formulas").Select
Range("B14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B13").Select
Sheets("Formulas").Select
Application.CutCopyMode = False
Sheets("Formulas").Copy Before:=Sheets(7)
Range("B13").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlToLeft).Select
Range("B13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B13").Select
Application.CutCopyMode = False
Sheets("Update Report").Select
Range("B3").Select
Selection.Copy
Sheets("Formulas (2)").Select
ActiveSheet.Name = Range("A2").Value
End Sub
I did try this, however ran into a "1004 Error: Application-defined or Object-defined error"
Any idea what might be causing this? When I click the debugger the last line is highlighted.
Here is a snippet of the later part of the code:
Range("A5:B5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Formulas").Select
Range("B14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B13").Select
Sheets("Formulas").Select
Application.CutCopyMode = False
Sheets("Formulas").Copy Before:=Sheets(7)
Range("B13").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlToLeft).Select
Range("B13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B13").Select
Application.CutCopyMode = False
Sheets("Update Report").Select
Range("B3").Select
Selection.Copy
Sheets("Formulas (2)").Select
ActiveSheet.Name = Range("A2").Value
End Sub
HansVogelaar
Oct 01, 2021MVP
Which sheet contains the cell with the name?
- mtschroeOct 01, 2021Copper ContributorIdeally the "Update Report" sheet / Cell B3. I did not know how to write in VBA, but have a reference to it in "Formulas (2)" / A1
- HansVogelaarOct 01, 2021MVP