Help naming a sheet from a macro

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
Hi

my macro currently creates a new sheet within another document called Analysis_v3.xlsm and gives it a name of yesterdays date

Workbooks.Open Filename:="filepath Analysis_v3.xlsm"
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = Format(Date - 1, "mm-dd")

however I would like the name of the new created sheet to come from a cell from within the workbook that exports the data.

anyone got any ideas?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Change workbook and sheet name and cell to match your data

Code:
ActiveSheet.Name =Workbooks(wbname). Sheets("Sheet1").Range("A1")
 
Last edited:
Upvote 0
Change workbook and sheet name and cell to match your data

Code:
ActiveSheet.Name =Workbooks(wbname). Sheets("Sheet1").Range("A1")


Hi

can it look for a workbook with a name_*.xml?

for example:
ActiveSheet.Name = Workbooks(Summary Form_*.xml).Sheets("Input1").Range("A2")

Do i also need to put the full path of the workbook?
ActiveSheet.Name = Workbooks(C:/Summary Form_*.xml).Sheets("Input1").Range("A2")

thanks again for any help
 
Upvote 0
Heres the full macro if that helps?

Sub ExportSummary()


Application.ScreenUpdating = False


Set range1 = ThisWorkbook.Sheets("Data FORM").Range("A7:H" & Range("A27").End(xlUp).Row)
Set range2 = ThisWorkbook.Sheets("Data FORM").Range("A28:H" & Range("A65").End(xlUp).Row)


Set multiplerange = Union(range1, range2)




multiplerange.Select
multiplerange.Copy


Workbooks.Open Filename:="L:Path\Analysis_v3.xlsm"
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = Workbooks(Summary_Form.xlsm).Sheets("Input1").Range("A2")
ActiveSheet.Cells(1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.Cells.Select
ActiveSheet.Cells.EntireColumn.AutoFit
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False


End Sub
 
Last edited:
Upvote 0
You are specifying a specific workbook otherwise the code does not know what workbook to use. You do not need the path, Summary_Form.xlsm should be open.

Code:
ActiveSheet.Name = Workbooks("Summary_Form.xlsm").Sheets("Input1").Range("A2")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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