Forum Discussion
anupambit1797
Oct 20, 2023Steel Contributor
Multiple-Worksheets creation
Dear Experts, Greetings! I have a case where , in the main sheet I have multiple unique entries in rows and want to create seperate worksheets for each of these rows( say abc, d...
HansVogelaar
Oct 23, 2023MVP
LET is an Excel function to be used in a formula. Formulas cannot create worksheets.
I don't think Power Query can create worksheets either, but I'm not an expert in Power Query.
anupambit1797
Oct 24, 2023Steel Contributor
Thanks HansVogelaar , also I see that this script doesn't work when the cell/row has a String like below
So, basically I wanted to create work sheet for each of these issues with a Single click(Script)
Attached is the worksheet
Thanks in Advance,
Br,
Anupam
- HansVogelaarOct 25, 2023MVP
The names are too long too - the maximum length of a sheet name is 31.
See the attached workbook for a modified version.
- SergeiBaklanOct 24, 2023MVP
Sheet name can't include [ or ], you need to define some logic for what to use instead.
- anupambit1797Oct 25, 2023Steel Contributor
ThanksSergeiBaklan , so if we can replace those [ or ] with "_" and then can we prepare some script to serve the purpose.
Thanks!
Br,
Anupam
- peiyezhuOct 25, 2023Bronze ContributorSub CreateSheetsFromNames()
'Create new sheets from the names added
'to column A beginning at A2 and down.
'Sheets added left-to-right.
Dim cel As Range, rng As Range
Application.ScreenUpdating = False
Set rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
For Each cel In rng
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name =application.WEBSERVICE("http://e.anyoupin.cn/eh3/?regreplace~[\[\]]~_~" & cel.Value)
'regular expression replace once or replace twice
Next cel
Application.ScreenUpdating = True
End Sub