PC Review


Reply
Thread Tools Rate Thread

Copy VB code from one worksheet to another using VBE

 
 
=?Utf-8?B?ZUR1ZGU=?=
Guest
Posts: n/a
 
      18th Oct 2006
I would like to know how to transfer code from one worksheet to another using
VBE and the password protect the second worksheet. I would like to all of
this using VB code in Excel!
 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      18th Oct 2006
Hi
Since you would only want to automate this if you have to do it lots of
times, why not create an Excel Add-In instead. This will separate your
code from the worksheets. If you need to update the code (and you will)
then you do it in the Add-In once and redistribute it, rather than
changing the code in lots of worksheets.
Add-In's are easy to do. You simply write code as normal in a workbook,
and use the Auto_Open and Close subs to create and delete a menu bar
for you so that you can apply your code to the active workbook. You
then set the Is Add-In? property of the workbook to true and that is
pretty much it.
Post back if this sounds like what you want and you want a bit more
detail.
regards
Paul

eDude wrote:
> I would like to know how to transfer code from one worksheet to another using
> VBE and the password protect the second worksheet. I would like to all of
> this using VB code in Excel!


 
Reply With Quote
 
=?Utf-8?B?ZUR1ZGU=?=
Guest
Posts: n/a
 
      19th Oct 2006
Dear Paul,

The purpose of my coping code is that there is a Master Sheet - A Tool that
creates tests (exams)". When the appropriate selections are made and I tell
the tool to create for eg: 10 tests, then tool creates 10 Random User IDs &
passwords along with file names and assigns to the 10 new workbooks. To these
10 new workbooks is where I would like to pass the code so the test features
get activated!

I have tried the below code found on the net, but it gives me an error that
"VB cannot trust to handover control..." or something like that!!!

Sub CopyOneModule()
Dim FName As String
With Workbooks("Book2")
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module1").Export FName
End With
Workbooks("book1").VBProject.VBComponents.Import FName
End Sub

If you can help me with this, that would be great.

Regards,
Mahesh

"(E-Mail Removed)" wrote:

> Hi
> Since you would only want to automate this if you have to do it lots of
> times, why not create an Excel Add-In instead. This will separate your
> code from the worksheets. If you need to update the code (and you will)
> then you do it in the Add-In once and redistribute it, rather than
> changing the code in lots of worksheets.
> Add-In's are easy to do. You simply write code as normal in a workbook,
> and use the Auto_Open and Close subs to create and delete a menu bar
> for you so that you can apply your code to the active workbook. You
> then set the Is Add-In? property of the workbook to true and that is
> pretty much it.
> Post back if this sounds like what you want and you want a bit more
> detail.
> regards
> Paul
>
> eDude wrote:
> > I would like to know how to transfer code from one worksheet to another using
> > VBE and the password protect the second worksheet. I would like to all of
> > this using VB code in Excel!

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to copy worksheet BeSmart Microsoft Excel Programming 5 14th Mar 2010 02:58 AM
Help with Code to Copy to New Worksheet prkhan56@gmail.com Microsoft Excel Programming 2 7th Feb 2007 06:17 PM
Copy Worksheet with Code Bill Microsoft Excel Programming 1 28th Sep 2005 10:21 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Microsoft Excel Programming 1 15th Apr 2004 08:34 PM
Copy Add-In Worksheet to Client Worksheet EXCLUDING VBA Code Mark D'Agosta Microsoft Excel Programming 1 8th Mar 2004 04:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:02 PM.