copying sheet

J

Jan Eikeland

envir excel in office97, winxphome
hi,
i copy one sheet from another but code for commandbutton wont follow.
any tips?
thank you
regards jan
 
B

Bob Phillips

Jan,

What type of CB is it, forms or control toolbox? I tried both (XP Pro,
XL2000), and they both copied the code, or macro assignment, as well.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

Jan Eikeland

its control
reg jan
Bob Phillips said:
Jan,

What type of CB is it, forms or control toolbox? I tried both (XP Pro,
XL2000), and they both copied the code, or macro assignment, as well.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

Jan,

As I said, when I copied a worksheet the Control CB worksheet code came over
with it.

How did you do the copy?
Where is the code (what code module)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

Jan Eikeland

hi, heres the sub:

Private Sub CommandButton1_Click()
With Worksheets("Elever")
For Each Cell In .Range(.Cells(1, 7), .Cells(Rows.Count, 7).End(xlUp))
If Not IsEmpty(Cell) Then
Worksheets("Elevmal").Copy After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Cell.Value
End If
Next
End With
End Sub
 
M

MSP77079

Are you copying a sheet or copying a range?

If you are using:

ActiveSheet.Cells.Copy
'go to place you want to place you want to paste to, then
Range("A1").Select
ActiveSheet.Paste

You will get only information in the cells, not the command buttons,
and not any code written on the sheet.

On the other hand, if you are using:

Sheets(n).Copy After:=Workbooks("Book2").Sheets(i)

then, you should get all the data and the command buttons, and the code
written on the sheet.
 
Top