Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-24-2016, 01:28 AM
gmayor's Avatar
gmayor gmayor is offline How to Control Users to edit Windows 10 How to Control Users to edit Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming that these are the first names of the usernames of your users, then you could employ something like the following.

Set the default state to be locked, and use password protection. Put the password in the macro where indicated and password protect the VBA project.

Save the worksheet as macro enabled, and if the users don't allow the code, they won't be able to edit anything, and they will only be able to edit any line that has the first name of their username in column A. You can modify this to suit your requirements.

Note that Excel is not a multi-user format. Only one person can have control of the workbook at a time.

Code:
Private Sub Workbook_Open()
'In the ThisWorkbook module of the workbook
Dim strName As String
Dim lngLast As Long, i As Integer
Const strPassword As String = "password" 'Your password
    lngLast = Cells(Rows.Count, "A").End(xlUp).Row
    strName = Trim(Split(Environ("UserName"), Chr(32))(0))
    ActiveSheet.Unprotect Password:=strPassword
    For i = 2 To lngLast
        If Not Cells(i, 1) = strName Then
            Rows(i).Locked = True
            'Rows(i).Hidden = True
        Else
            Rows(i).Locked = False
            'Rows(i).Hidden = False
        End If
    Next i
    ActiveSheet.Protect Password:=strPassword
lbl_Exit:
    Exit Sub
End Sub
Damn. I hadn't seen the moderator's comment before posting
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 07-27-2016, 07:06 PM
dolphine4u dolphine4u is offline How to Control Users to edit Windows 10 How to Control Users to edit Office 2013
Novice
How to Control Users to edit
 
Join Date: Jul 2016
Posts: 3
dolphine4u is on a distinguished road
Default Thanks pls close this

Dear gmayor,

Thanks a lot that was exactly what i was looking for it works great.

Regards,
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Box Content Control when checked users are presented with an option cryder Word 0 01-07-2016 05:11 AM
How to Control Users to edit Edit table in content control denise do rocio maciel Word VBA 2 01-03-2016 11:59 PM
How to Control Users to edit Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
How to Control Users to edit Word 2003 Document Opens In control toolbox Edit Mode rangasamy007 Word 1 09-16-2011 04:12 AM
Set text in edit control on inspector window indicating time Outlook 2007 saniltalathi Outlook 0 02-20-2009 08:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft