How To Remove VBA Code For Distribution of an Excel Sheet


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Excel Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Excel Forum Members Post questions in this forum if they are related to using Microsoft Excel, this includes Worksheet Functions, Excel VBA Programming, Simple Macro Code & Charting, Excel formula etc.

New Reply
Thread Tools Rate Thread Display Modes
  #1  
Unread 27th May 2010, 21:34
G's Avatar
G
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default How To Remove VBA Code For Distribution of an Excel Sheet
     Excel: VBA   


------ Register to get rid of these "In Post" ads! ------

Category: Excel: VBA   

I am currently using Excel 2003. I have written some VBA Code in a worksheet.

I have 2 worksheet. The 1s worksheet is required by users to see and use,
and the 2nd worksheet is not required by the user, but I need it for my VBA
code and other things.

Is there a way to distribute my excel sheet such that others will not be
able to see my code or 2nd worksheet?? 1st of all, I would like the VBA
code to be not available to my users to see. If I can I would like the 2nd
worksheet not available for them to see either. The removal of the VBA code
is more important to me.

I would appreciate any help you can offer.


Thank You,

G

The Code Cage Advertisment
Advertisement
  #2  
Unread 27th May 2010, 23:26
JLGWhiz's Avatar
JLGWhiz
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: How To Remove VBA Code For Distribution of an Excel Sheet

------ Register to get rid of these "In Post" ads! ------


The answer is yes. Now, depending on where your VBA code resides will
depend on how you do what you want to do.

1. If the code resides in a public code module (these are the ones named
Module1,
Module2, etc. in the Project pane of the VB editor window.) then it is
pretty simple.
Set newWB = Sheets("Sheet1").Copy
ActiveWorkbooik.SaveAs Filename:="<giveitanewname> .xls"
The sheets.copy method creates a new workbook with one worksheet and
does not
copy the code from the public module.

2. If the code resides in the Worksheet code module you have two things
to consider.
a. Will the worksheet be useful to the user without the code?
b. Will removing the code from the worksheet code module affect the
data?

If 2.a is Yes and 2.b is No, then:

Set newWB = Workbooks.Add
Workbooks(1).Sheets("Sheet1").Cells.Copy neWB
newWB.Sheets(1).Range("A1")
This method copies formulas and formats as well as the data, but does
not bring over
any code from VBA. If you do not want formulas and format, then use
PasteSpecial.



"G" <G@discussions.microsoft.com> wrote in message
news:57160FFB-AC2A-4D5B-813C-9A57EC69E84A@microsoft.com...
>I am currently using Excel 2003. I have written some VBA Code in a
>worksheet.
>
> I have 2 worksheet. The 1s worksheet is required by users to see and use,
> and the 2nd worksheet is not required by the user, but I need it for my
> VBA
> code and other things.
>
> Is there a way to distribute my excel sheet such that others will not be
> able to see my code or 2nd worksheet?? 1st of all, I would like the VBA
> code to be not available to my users to see. If I can I would like the
> 2nd
> worksheet not available for them to see either. The removal of the VBA
> code
> is more important to me.
>
> I would appreciate any help you can offer.
>
>
> Thank You,
>
> G




  #3  
Unread 28th May 2010, 19:24
Jon Peltier's Avatar
Jon Peltier
Newsgroup Contributor
 
Posts: n/a
Posts Per Day: 0
My Top Tip Count:
Default Re: How To Remove VBA Code For Distribution of an Excel Sheet

------ Register to get rid of these "In Post" ads! ------


If you have not put any code in the code module behind the first
worksheet, right click on the sheet tab, choose Move or Copy, select New
Workbook, check Create a Copy, and click Enter. The result is a
one-worksheet workbook with only the sheet you want and no code.

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/


On 5/27/2010 4:30 PM, G wrote:
> I am currently using Excel 2003. I have written some VBA Code in a worksheet.
>
> I have 2 worksheet. The 1s worksheet is required by users to see and use,
> and the 2nd worksheet is not required by the user, but I need it for my VBA
> code and other things.
>
> Is there a way to distribute my excel sheet such that others will not be
> able to see my code or 2nd worksheet?? 1st of all, I would like the VBA
> code to be not available to my users to see. If I can I would like the 2nd
> worksheet not available for them to see either. The removal of the VBA code
> is more important to me.
>
> I would appreciate any help you can offer.
>
>
> Thank You,
>
> G


The Code Cage Advertisment
Advertisement
New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
code, distribution, excel, remove, sheet, vba

Thread Tools
Display Modes 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

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 09:29.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University