Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How can I copy sheet, fill in cell from list and rename worksheet?

Ok...I need to know how to do the following.

I have a worksheet that I need to copy, fill in cell I6 with a value
from a worksheet named Employees (first cell is C79) and then rename
the newly created sheet with the value that is in cell I6 of that newly
created worksheet. I need this to repeat a copy until it it gets
through cell C108 of the Employees worksheet.

Thank you oh wise and mighty Excel gurus.

Lee

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How can I copy sheet, fill in cell from list and rename worksheet?

Maybe something like:

Option Explicit
Sub testme()

Dim CopyWks As Worksheet
Dim EmpWks As Worksheet
Dim NewWks As Worksheet

Dim RngNames As Range
Dim myCell As Range

Set CopyWks = Worksheets("sheettocopy")
Set EmpWks = Worksheets("Employees")

Set RngNames = EmpWks.Range("C79:c108")

For Each myCell In RngNames.Cells
CopyWks.Copy _
after:=Sheets(Sheets.Count)
Set NewWks = ActiveSheet
With NewWks
.Range("i6").Value = myCell.Value
On Error Resume Next
.Name = myCell.Value
If Err.Number < 0 Then
MsgBox "Please fix sheet: " & .Name & " manually!"
Err.Clear
End If
On Error GoTo 0
End With
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

wrote:

Ok...I need to know how to do the following.

I have a worksheet that I need to copy, fill in cell I6 with a value
from a worksheet named Employees (first cell is C79) and then rename
the newly created sheet with the value that is in cell I6 of that newly
created worksheet. I need this to repeat a copy until it it gets
through cell C108 of the Employees worksheet.

Thank you oh wise and mighty Excel gurus.

Lee


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How can I copy sheet, fill in cell from list and rename worksheet?

This works great.. but being a rookie, I stated something incorrectly.
The worksheet should be named for what is in I5. I6 is what I am
populating from C79:c108, but the worksheet name will come from I5 of
the newly created worksheet. THANKS FOR YOUR HELP!


Dave Peterson wrote:
Maybe something like:

Option Explicit
Sub testme()

Dim CopyWks As Worksheet
Dim EmpWks As Worksheet
Dim NewWks As Worksheet

Dim RngNames As Range
Dim myCell As Range

Set CopyWks = Worksheets("sheettocopy")
Set EmpWks = Worksheets("Employees")

Set RngNames = EmpWks.Range("C79:c108")

For Each myCell In RngNames.Cells
CopyWks.Copy _
after:=Sheets(Sheets.Count)
Set NewWks = ActiveSheet
With NewWks
.Range("i6").Value = myCell.Value
On Error Resume Next
.Name = myCell.Value
If Err.Number < 0 Then
MsgBox "Please fix sheet: " & .Name & " manually!"
Err.Clear
End If
On Error GoTo 0
End With
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

wrote:

Ok...I need to know how to do the following.

I have a worksheet that I need to copy, fill in cell I6 with a value
from a worksheet named Employees (first cell is C79) and then rename
the newly created sheet with the value that is in cell I6 of that newly
created worksheet. I need this to repeat a copy until it it gets
through cell C108 of the Employees worksheet.

Thank you oh wise and mighty Excel gurus.

Lee


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How can I copy sheet, fill in cell from list and rename worksheet?

If I5 is a constant, then you'll have trouble. If I5 is a formula, then this
should work:

Change:
..Name = myCell.Value
to
..Name = .range("i5").Value



wrote:

This works great.. but being a rookie, I stated something incorrectly.
The worksheet should be named for what is in I5. I6 is what I am
populating from C79:c108, but the worksheet name will come from I5 of
the newly created worksheet. THANKS FOR YOUR HELP!

Dave Peterson wrote:
Maybe something like:

Option Explicit
Sub testme()

Dim CopyWks As Worksheet
Dim EmpWks As Worksheet
Dim NewWks As Worksheet

Dim RngNames As Range
Dim myCell As Range

Set CopyWks = Worksheets("sheettocopy")
Set EmpWks = Worksheets("Employees")

Set RngNames = EmpWks.Range("C79:c108")

For Each myCell In RngNames.Cells
CopyWks.Copy _
after:=Sheets(Sheets.Count)
Set NewWks = ActiveSheet
With NewWks
.Range("i6").Value = myCell.Value
On Error Resume Next
.Name = myCell.Value
If Err.Number < 0 Then
MsgBox "Please fix sheet: " & .Name & " manually!"
Err.Clear
End If
On Error GoTo 0
End With
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

wrote:

Ok...I need to know how to do the following.

I have a worksheet that I need to copy, fill in cell I6 with a value
from a worksheet named Employees (first cell is C79) and then rename
the newly created sheet with the value that is in cell I6 of that newly
created worksheet. I need this to repeat a copy until it it gets
through cell C108 of the Employees worksheet.

Thank you oh wise and mighty Excel gurus.

Lee


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How can I copy sheet, fill in cell from list and rename worksheet?

THANK YOU! That worked flawlessly!

lee


Dave Peterson wrote:
If I5 is a constant, then you'll have trouble. If I5 is a formula, then this
should work:

Change:
.Name = myCell.Value
to
.Name = .range("i5").Value



wrote:

This works great.. but being a rookie, I stated something incorrectly.
The worksheet should be named for what is in I5. I6 is what I am
populating from C79:c108, but the worksheet name will come from I5 of
the newly created worksheet. THANKS FOR YOUR HELP!

Dave Peterson wrote:
Maybe something like:

Option Explicit
Sub testme()

Dim CopyWks As Worksheet
Dim EmpWks As Worksheet
Dim NewWks As Worksheet

Dim RngNames As Range
Dim myCell As Range

Set CopyWks = Worksheets("sheettocopy")
Set EmpWks = Worksheets("Employees")

Set RngNames = EmpWks.Range("C79:c108")

For Each myCell In RngNames.Cells
CopyWks.Copy _
after:=Sheets(Sheets.Count)
Set NewWks = ActiveSheet
With NewWks
.Range("i6").Value = myCell.Value
On Error Resume Next
.Name = myCell.Value
If Err.Number < 0 Then
MsgBox "Please fix sheet: " & .Name & " manually!"
Err.Clear
End If
On Error GoTo 0
End With
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

wrote:

Ok...I need to know how to do the following.

I have a worksheet that I need to copy, fill in cell I6 with a value
from a worksheet named Employees (first cell is C79) and then rename
the newly created sheet with the value that is in cell I6 of that newly
created worksheet. I need this to repeat a copy until it it gets
through cell C108 of the Employees worksheet.

Thank you oh wise and mighty Excel gurus.

Lee

--

Dave Peterson


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy worksheet and rename sheet Ernst - EXE Graphics Excel Discussion (Misc queries) 4 July 25th 08 01:18 PM
Copy worksheet, rename, merged cell problem?? Simon Lloyd[_779_] Excel Programming 2 June 16th 06 01:06 PM
How to copy a sheet and rename it with the value of two cells from the source sheet? Simon Lloyd[_717_] Excel Programming 0 May 12th 06 01:31 AM
Copy/Rename a sheet DK Links and Linking in Excel 1 March 20th 06 05:36 AM
Button to copy sheet, rename sheet sequencially. foxgguy2005[_3_] Excel Programming 9 June 17th 05 01:41 PM


All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"