fivegallon
Board Regular
- Joined
- Jun 26, 2005
- Messages
- 50
Hi, i'm wanting to add a new worksheet when i add an entry to an index page with the same name as the new entry.
I have the code for this bit already.
What i would like it to do is to copy an existing sheet that already has the layout i require rather than just a new blank sheet
My workbook is multiple worksheets on motor testing data.
The first page is "Index".
Each entry is hyperlinked to subsequent worksheets of motor test data.
The second page is "Motor Info Sheet Blank".
This is the page i would like to copy
I would prefer if i can insert the new page immediately into the "third" position each time rather than at the "end".
This will keep the most recent data within initial view. If this part can't be done and it needs to go to the "end", then no big deal
Here is my current code:
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br><SPAN style="color:#00007F">Dim</SPAN> wsNew <SPAN style="color:#00007F">As</SPAN> Worksheet<br><SPAN style="color:#00007F">If</SPAN> Target.Cells.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br>****<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>****<SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> Intersect(Target, Range("A1:A50")) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN><br>****<SPAN style="color:#00007F">Set</SPAN> wsNew = Sheets(Target.Text)<br>****<SPAN style="color:#00007F">If</SPAN> wsNew <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> Sheets.Add().Name = Target.Text<br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
Edit: i'm using Excel 2007
I have the code for this bit already.
What i would like it to do is to copy an existing sheet that already has the layout i require rather than just a new blank sheet
My workbook is multiple worksheets on motor testing data.
The first page is "Index".
Each entry is hyperlinked to subsequent worksheets of motor test data.
The second page is "Motor Info Sheet Blank".
This is the page i would like to copy
I would prefer if i can insert the new page immediately into the "third" position each time rather than at the "end".
This will keep the most recent data within initial view. If this part can't be done and it needs to go to the "end", then no big deal
Here is my current code:
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br><SPAN style="color:#00007F">Dim</SPAN> wsNew <SPAN style="color:#00007F">As</SPAN> Worksheet<br><SPAN style="color:#00007F">If</SPAN> Target.Cells.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br>****<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>****<SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> Intersect(Target, Range("A1:A50")) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN><br>****<SPAN style="color:#00007F">Set</SPAN> wsNew = Sheets(Target.Text)<br>****<SPAN style="color:#00007F">If</SPAN> wsNew <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> Sheets.Add().Name = Target.Text<br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
Edit: i'm using Excel 2007