#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Hide Macro


Hello
Im using the following macros to protect/unprotect all sheets in my work book.

Sub Protect_sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="password"
Next ws
End Sub

Sub unprotect_sheets()

Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="password"
Next ws
End Sub

For my use I would like to assign a hot key to run the macros but I would
also like to hide the macros from other users I suppose my making the code
private. Apparently I cant do this because when I make the code private my
hot keys don't work.

How can I accomplish both requirements?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,276
Default Hide Macro


Hi,
You can do that with a password in your VBA module, however passwords in
excel can be broken

go to your VBA application, tools, VBAProject - Project Properties,
Protection, enter your password, then each time you want to go to VBA to see
the macros it will ask for the password

To apply macro to a button, go to Developer, Insert, insert your button and
assign the Macro,
"Thanks" wrote:

Hello
Im using the following macros to protect/unprotect all sheets in my work book.

Sub Protect_sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="password"
Next ws
End Sub

Sub unprotect_sheets()

Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="password"
Next ws
End Sub

For my use I would like to assign a hot key to run the macros but I would
also like to hide the macros from other users I suppose my making the code
private. Apparently I cant do this because when I make the code private my
hot keys don't work.

How can I accomplish both requirements?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Hide Macro


Thanks for your reply.
Well I had already protected the module. I added 2 buttons and assigned the
macros but the code still runs without password when clicked.


"Eduardo" wrote:

Hi,
You can do that with a password in your VBA module, however passwords in
excel can be broken

go to your VBA application, tools, VBAProject - Project Properties,
Protection, enter your password, then each time you want to go to VBA to see
the macros it will ask for the password

To apply macro to a button, go to Developer, Insert, insert your button and
assign the Macro,
"Thanks" wrote:

Hello
Im using the following macros to protect/unprotect all sheets in my work book.

Sub Protect_sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="password"
Next ws
End Sub

Sub unprotect_sheets()

Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="password"
Next ws
End Sub

For my use I would like to assign a hot key to run the macros but I would
also like to hide the macros from other users I suppose my making the code
private. Apparently I cant do this because when I make the code private my
hot keys don't work.

How can I accomplish both requirements?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,276
Default Hide Macro


Hi,
I think I misunderstood what you wanted, if you want a password to be
entered when pushing the button and no all users having access to it, create
a new sheet where you will place the buttons, right click on the mouse in
that new sheet, view code, paste this
Private Sub Worksheet_Activate()
Dim strPassword As String
On Error Resume Next
Me.Protect Password:="MANAGER"
Me.Columns.Hidden = True

strPassword = InputBox("Enter password to access DATA sheet")

If strPassword = "" Then
ActiveSheet.Visible = False
Worksheets("Menu").Select
Exit Sub
ElseIf strPassword < "MANAGER" Then
MsgBox "Password Incorrect "
ActiveSheet.Visible = False
Worksheets("Menu").Select
Exit Sub
Else
Me.Unprotect Password:="MANAGER"
Me.Columns.Hidden = False
End If
Range("a1").Select

On Error GoTo 0
End Sub

Private Sub Worksheet_Deactivate()
On Error Resume Next
Me.Columns.Hidden = True
On Error GoTo 0
End Sub

then hide the sheet, and in your main sheet place a buttom to open this
sheet, at that time it will ask for the password to unhide it.
Hope this helps



"Thanks" wrote:

Thanks for your reply.
Well I had already protected the module. I added 2 buttons and assigned the
macros but the code still runs without password when clicked.


"Eduardo" wrote:

Hi,
You can do that with a password in your VBA module, however passwords in
excel can be broken

go to your VBA application, tools, VBAProject - Project Properties,
Protection, enter your password, then each time you want to go to VBA to see
the macros it will ask for the password

To apply macro to a button, go to Developer, Insert, insert your button and
assign the Macro,
"Thanks" wrote:

Hello
Im using the following macros to protect/unprotect all sheets in my work book.

Sub Protect_sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="password"
Next ws
End Sub

Sub unprotect_sheets()

Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="password"
Next ws
End Sub

For my use I would like to assign a hot key to run the macros but I would
also like to hide the macros from other users I suppose my making the code
private. Apparently I cant do this because when I make the code private my
hot keys don't work.

How can I accomplish both requirements?

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
Hide a Macro [email protected] Excel Discussion (Misc queries) 2 July 26th 07 09:12 AM
macro to hide row with 0.00 Lori Excel Worksheet Functions 2 April 25th 07 08:56 PM
how to hide a macro name from macro listings MVM Excel Programming 2 May 10th 06 08:44 PM
Hide Macro astrikor Excel Programming 3 March 1st 06 12:03 PM
hide macro GM[_4_] Excel Programming 1 January 27th 05 03:46 PM


All times are GMT +1. The time now is 11:49 PM.

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

About Us

"It's about Microsoft Excel"