Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Programically remove code from a worksheet

I have a workbook that I need to copy a particular sheet out to save in a
separate workbook. This part is done and works.
The worksheet has an Activate piece that shows a user form. When I copy the
worksheet into its own workbook, programically, the code comes with it. When
the sheet is activated in the new workbook the code erros out because the
user form is not copied over with it, the userform is not needed in the new
workbook. How can I programically removed the Worksheet_Activate code when
the worksheet is programically copied out?

Thanks for any help
--
Stephen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Programically remove code from a worksheet

hi
see this site
http://cpearson.com/excel/vbe.aspx
make note of the warning.

Regards
FSt1

"Stephen sjw_ost" wrote:

I have a workbook that I need to copy a particular sheet out to save in a
separate workbook. This part is done and works.
The worksheet has an Activate piece that shows a user form. When I copy the
worksheet into its own workbook, programically, the code comes with it. When
the sheet is activated in the new workbook the code erros out because the
user form is not copied over with it, the userform is not needed in the new
workbook. How can I programically removed the Worksheet_Activate code when
the worksheet is programically copied out?

Thanks for any help
--
Stephen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Programically remove code from a worksheet

You may be happier copying and pasting the data vs. trying to delete the code.
I avoid writing code that alters code if at all possible.
If you must/want/have to do that then Chip Pearson's website has instructions...
http://www.cpearson.com/excel/vbe.aspx

Alternatively, something like the following can be used...
'--
Sub PutErThere()
Dim rng As Range
'Find the bottom right cell
Set rng = ThisWorkbook.Worksheets _
("Sludge").Cells.SpecialCells(xlCellTypeLastCel l)
'Establish the range to copy
Set rng = ThisWorkbook.Worksheets _
("Sludge").Range("A1", rng)
'Copy and paste
rng.Copy _
Destination:=Workbooks("NewBook").Worksheets(1).Ra nge("A1")
'Clean up
Application.CutCopyMode = False
Set rng = Nothing
End Sub
--
Jim Cone
Portland, Oregon USA




"Stephen sjw_ost"

wrote in message
I have a workbook that I need to copy a particular sheet out to save in a
separate workbook. This part is done and works.
The worksheet has an Activate piece that shows a user form. When I copy the
worksheet into its own workbook, programically, the code comes with it. When
the sheet is activated in the new workbook the code erros out because the
user form is not copied over with it, the userform is not needed in the new
workbook. How can I programically removed the Worksheet_Activate code when
the worksheet is programically copied out?

Thanks for any help
--
Stephen
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
programically refresh pivot chart formatting Todd F.[_2_] Excel Programming 2 June 20th 06 06:21 PM
Problem with Updating Add-in path programically loshy Excel Programming 0 October 26th 05 07:18 AM
Remove VBA code behind a worksheet BAC Excel Programming 2 October 11th 05 02:35 PM
How do you programically remove carriage returns within a cell Lee Excel Programming 2 July 20th 05 06:43 PM
remove code from behind worksheet mark kubicki Excel Programming 3 April 28th 05 02:57 PM


All times are GMT +1. The time now is 03:15 PM.

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"