dngsullivan
New Member
- Joined
- Jul 3, 2017
- Messages
- 24
Hi there,
I'm a complete newbie at VBA, only looked at my first code this week!
After searching many forums (thanks for your help everyone!) I have modified code to work somewhat.
My macro currently copies a template and renames it based on data on my "estimate" sheet, what I need help with is:
1. How do I get the sheets to add in the same order of the data - it currently adds it in backwards (eg sheets appear as Estimate, Room4, Room3, Room2, Room1, Template - I would like it to be Estimate, Room 1,2,3,4, Template)
2. If after the macro has been run, I want to add to the list (eg. Room 5 & Room6), how can I get it to run the macro but ignore sheets already added. I currently receive "RTE 1004: That name is already taken. Try a different one"
3. If possible, can this macro be modified and assigned to buttons next to each room name, so I can create a sheet individually - this may help me with question 2 above.
Thanks in advance!
I'm a complete newbie at VBA, only looked at my first code this week!
After searching many forums (thanks for your help everyone!) I have modified code to work somewhat.
My macro currently copies a template and renames it based on data on my "estimate" sheet, what I need help with is:
1. How do I get the sheets to add in the same order of the data - it currently adds it in backwards (eg sheets appear as Estimate, Room4, Room3, Room2, Room1, Template - I would like it to be Estimate, Room 1,2,3,4, Template)
2. If after the macro has been run, I want to add to the list (eg. Room 5 & Room6), how can I get it to run the macro but ignore sheets already added. I currently receive "RTE 1004: That name is already taken. Try a different one"
3. If possible, can this macro be modified and assigned to buttons next to each room name, so I can create a sheet individually - this may help me with question 2 above.
Code:
Sub NewSheets()
Dim i As Integer
Dim ws As Worksheet
Dim sh As Worksheet
Set ws = Sheets("Template")
Set sh = Sheets("Estimate")
Application.ScreenUpdating = 0
For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
Sheets("Template").Copy After:=sh
ActiveSheet.Name = sh.Range("A" & i).Value
Next i
End Sub
Thanks in advance!