Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default password protecting a column for data entry in a sheet, how?

i have a work sheet that will be used by two users/computers, in the same
domain but have different IP's. i want to restrict the other user to enter
the data in a single column only and that data entry will be password
pretected at his end, so that i cannot enter the data in his range.

can any one provide me a solution to this issue?
awaiting for reply,

regards,

kashi.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default password protecting a column for data entry in a sheet, how?

If you know the username that the two users log into the system with, then
possibly this is a solution. This code would go into the worksheet's code
module. This code will only allow a specific username to enter anything in
column C, and will keep that same user from entering anything into any other
cell on the sheet. It isn't perfect - doesn't take into consideration
selecting multiple cells that may or may not include the 'protected' column.

To test this out, choose the sheet with the 'special' column and right-click
on its name tab and choose [View Code] from the list of options. Cut and
paste the code below into that module - change the username as needed. The
username is what you/they use to log into Windows, not the password, but the
username.

Option Explicit
' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Private Declare Function GetUserName Lib _
"advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Private Function Get_Win_User_Name() As String

' Dimension variables
Dim lpBuff As String * 25
Dim ret As Long

' Get the user name minus any
' trailing spaces found in the name.
ret = GetUserName(lpBuff, 25)
Get_Win_User_Name = Left(lpBuff, _
InStr(lpBuff, Chr(0)) - 1)

End Function

Private Sub Worksheet_SelectionChange(ByVal _
Target As Range)
'assumes that only a user named John may
'make entries into column C (column #3)
'and
'that John may not make entries anywhere else
'on the worksheet
'
'the usernames must be typed into this code
'using ALL CAPS
'
Dim userName As String

userName = UCase(Get_Win_User_Name())
If userName = "JOHN" Then
If Target.Column = 3 Then ' in column C
Exit Sub ' let john make changes in C
Else
' force John into C
Range("C" & Target.Row).Select
End If
End If
'user is not JOHN, only he may make changes in C
If Target.Column = 3 Then
'force the selected cell to someplace else
Range("A" & Target.Row).Select
'if you want to explain things:
MsgBox _
"You are not permitted to make changes in cell " & _
Target.Address
End If
End Sub


"kashi" wrote:

i have a work sheet that will be used by two users/computers, in the same
domain but have different IP's. i want to restrict the other user to enter
the data in a single column only and that data entry will be password
pretected at his end, so that i cannot enter the data in his range.

can any one provide me a solution to this issue?
awaiting for reply,

regards,

kashi.

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
automatic column sorting problem when protecting sheet Montana Excel Worksheet Functions 3 May 17th 07 09:55 AM
Protecting excel sheet for data input rdrnws Excel Discussion (Misc queries) 1 November 23rd 06 10:38 AM
Excel (Office 2007 B2TR) -- Password Protecting A Sheet -- Character Limit ? Office2007B2TR_Tester_91311 Excel Discussion (Misc queries) 2 October 12th 06 07:08 PM
How do I lock the Column without Protecting the Sheet sgmoorthy Excel Discussion (Misc queries) 2 November 4th 05 02:00 PM
Sheet Protecting password Nick Excel Discussion (Misc queries) 1 June 30th 05 12:43 AM


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