vba xcel

S

siza_05

peace to everyone!
i used xcel 2007 n also vba which in there..

i want user login to my worksheet..so how can i do that..?

thanks!
 
J

james.billy

peace to everyone!
 i used xcel 2007 n also vba which in there..

i want user login to my worksheet..so how can i do that..?

thanks!

One way would be to create a userform, with username and password (you
can set a text box property password chr to * or something to hide the
password), the command button would then do a lookup against a sheet
and work out if the username and password match, if they dont you
could keep a count of attemps and after three close the workbook.

You would then show the form from the workbook open event.

You would also need to control saving the workbook (using the workbook
save event) to ensure that sheets are not left visible (otherwise I
could just disable the macros and gain access), a workaround could be
to put the login form in another workbook and when your user enters
the correct username and password it then opens the real workbook
(this would depend on whether all your users are on the same network
etc.)...

Please note that after doing all this it still is not at all secure...
To make it slightly more secure, you would make the sheet holding the
password/username as "Very hidden" and lock the vba project again
anyone could run code against the workbook to extract the usernames
and passwords, another way would be to hold the usernames and
passwords in vba but then you have a maintenance issue.

A simpler and much more secure route would be put a password on the
excel file but then it depends on what your trying to accomplish?!

James
 
S

siza_05

One way would be to create a userform, with username and password (you
can set a text box property password chr to * or something to hide the
password), the command button would then do a lookup against a sheet
and work out if the username and password match, if they dont you
could keep a count of attemps and after three close the workbook.

You would then show the form from the workbook open event.

You would also need to control saving the workbook (using the workbook
save event) to ensure that sheets are not left visible (otherwise I
could just disable the macros and gain access), a workaround could be
to put the login form in another workbook and when your user enters
the correct username and password it then opens the real workbook
(this would depend on whether all your users are on the same network
etc.)...

Please note that after doing all this it still is not at all secure...
To make it slightly more secure, you would make the sheet holding the
password/username as "Very hidden" and lock the vba project again
anyone could run code against the workbook to extract the usernames
and passwords, another way would be to hold the usernames and
passwords in vba but then you have a maintenance issue.

A simpler and much more secure route would be put a password on the
excel file but then it depends on what your trying to accomplish?!

James

thanks james...for reply me..
yes i know about about userform..but how i want to match a password n
username..do we need a databasa/worksheet that save all the username n
password?
if yes,how i can access that database?
just like vb+access..
for vb+acess...i know but
vb+excel..i not really good enough

thanks! peace!
 
R

ryguy7272

This is how I do it:
Private Sub CommandButton1_Click()


Dim i_pwd As String

i_pwd = InputBox("Please Enter Password to Unhide Sheet", "Unhide Sheet...")
If i_pwd = "" Then
Exit Sub
End If

'#1
Select Case (i_pwd)
Case Is = "showfirst"
Worksheets("Person#1").Visible = True
Worksheets("Person#2").Visible = True
Worksheets("Person#3").Visible = True

'#2

Case Is = "showsecond"
Worksheets("Person#4").Visible = True
Worksheets("Person#5").Visible = True
Worksheets("Person#6").Visible = True

Case Else
MsgBox "Incorrect password; no action taken.", vbInformation, _
"Unhide Sheet..."
End Select

Exit Sub


End Sub


Regards,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top