Rhodie72
Well-known Member
- Joined
- Apr 18, 2016
- Messages
- 633
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2010
- 2007
- 2003 or older
- Platform
- Windows
- Mobile
I am wanting to add a new sheet of data and name the new sheet by the text in another sheet. I'm not looking for a dynamic name change as it is just copy and paste data going into it. I keep geting a debug error... lol.
And whilst writing this I realised I was being stupid and created the solution, so here's the answer to my question which I hope will help somebody, somewhere, achieve something useful in their life.
And whilst writing this I realised I was being stupid and created the solution, so here's the answer to my question which I hope will help somebody, somewhere, achieve something useful in their life.
VBA Code:
Sub Create_New_Payslip()
'
'
Dim MyName As String
MyName = Sheets("UTF-8").Range("C26").Text
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = MyName
Sheets("UTF-8").Range("A1:K27").Cut
With Sheets(MyName)
.Paste
.Columns("A:K").EntireColumn.AutoFit
End With
Sheets("UTF-8").Range("A1").Select
MyName =empty 'Memory management
End Sub