Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code to ask for password to get access to sheet

Hi,

I have put the code I got from this forum, (Thanks Simon) in a module
taken away the apostrophs, and it all works fine, until I type th
password.
I want to get access and automatically jump to the sheet named hidden

Now, I stay put in the same sheet as I have placed the "accessbutton".

What have I missed here?

Thanks in advance

//Thomas

Sub pw()
'
' msg Macro

'
' Keyboard Shortcut: Ctrl+Shift+M
Dim t1 As String
Dim I1 As Integer
Dim I2 As Integer

I1 = MsgBox("Continue", 292, "Password?")
If I1 = 6 Then
For I2 = 1 To 3
t1 = InputBox("Password", "Input", "")
If t1 = "simon" Or t1 = "mark" Then
Sheet("hidden") = t1
Exit Sub
Else
Worksheets("hidden").Visible = True
Worksheets("hidden").Select
ActiveSheet.Range("a2").Select
Selection.Insert Shift:=xlDown
Selection = t1
Worksheets("hidden").Visible = False
End If
Next 'I2

MsgBox "Access denied " & Chr(13) & "The program is closing" & t1
ActiveWorkbook.Close savechanges:=True
End If


End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default code to ask for password to get access to sheet

2 things I noticed:
Sheet("hidden") = t1
should be (?)
Sheets("hidden").Name = t1

and 'hidden' is a reserved word in Excel and could creat some conflicts with
the system.
Suggest you change it to something else (maybe: 'hidn')

Suspect that you don't have 'Option Explicit' at the top of your module.
That's what spotted 'Sheet("hidden") = t1' as
being a problem.... (after I tried to compile the code).

--
steveb
(Remove 'NOSPAM' from email address if replying direct)


"Jonsson " wrote in message
...
Hi,

I have put the code I got from this forum, (Thanks Simon) in a module,
taken away the apostrophs, and it all works fine, until I type the
password.
I want to get access and automatically jump to the sheet named hidden.

Now, I stay put in the same sheet as I have placed the "accessbutton".

What have I missed here?

Thanks in advance

//Thomas

Sub pw()
'
' msg Macro

'
' Keyboard Shortcut: Ctrl+Shift+M
Dim t1 As String
Dim I1 As Integer
Dim I2 As Integer

I1 = MsgBox("Continue", 292, "Password?")
If I1 = 6 Then
For I2 = 1 To 3
t1 = InputBox("Password", "Input", "")
If t1 = "simon" Or t1 = "mark" Then
Sheet("hidden") = t1
Exit Sub
Else
Worksheets("hidden").Visible = True
Worksheets("hidden").Select
ActiveSheet.Range("a2").Select
Selection.Insert Shift:=xlDown
Selection = t1
Worksheets("hidden").Visible = False
End If
Next 'I2

MsgBox "Access denied " & Chr(13) & "The program is closing" & t1
ActiveWorkbook.Close savechanges:=True
End If


End Sub


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code to ask for password to get access to sheet

Hi,

I modified the code and now it works perfect!

Thanks Simon for sharing the code from the beginning!!

So, here you are, a code that asks for password to get access to
certain sheet. The sheet has to be very hidden, of course.
I am aware that its a really bad protection, but it stops the averag
user from get access, I hope.

//Thomas


Sub pw()
'
' msg Macro

'
' Keyboard Shortcut: Ctrl+Shift+M
Dim t1 As String
Dim I1 As Integer
Dim I2 As Integer
Dim Worksheets As Sheets
I1 = MsgBox("Go on?", 291, "Password?")
If I1 = 6 Then
For I2 = 1 To 3
t1 = InputBox("Password", "?", "")
If t1 = "simon" Or t1 = "mark" Then
Sheets("hid").Visible = True
Sheets("hid").Select
Exit Sub
Else
'Worksheets("hid").Visible = True
'Worksheets("hid").Select
'Range("a2").Select
'Selection.Insert Shift:=xlDown
Selection = t1
'Worksheets("hid").Visible = False
End If
Next 'I2

MsgBox "Access denied " & Chr(13) & "The programme will shut down"
t1
ActiveWorkbook.Close savechanges:=True
'Application.Quit

End If

End Su

--
Message posted from http://www.ExcelForum.com

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
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
is there anyway to make it so the users of my excel spread sheet cant view the macro code w/o a password? Daniel Excel Worksheet Functions 2 June 28th 05 05:34 AM
linking excel sheet to access using code Charles Excel Programming 0 January 30th 04 07:24 AM
Access protected VB code by initiating password dialog box WashoeJeff Excel Programming 0 January 30th 04 06:09 AM
Password to get access to certain sheet Jonsson Excel Programming 1 January 10th 04 03:46 PM


All times are GMT +1. The time now is 10:28 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"