Excel WINNT Macro

Microsoft Microsoft excel 2000
October 28, 2009 at 05:23:39
Specs: Windows XP
Restrict, or allow, the alteration of a spreadsheet, by selected people, that is on a shared network, based on WINNT user ID. This should be transparent and users that are allowed will never see a message. However, users that are restricted will only see a message if they try to alter the file.

See More: Excel WINNT Macro

Report •

October 28, 2009 at 08:28:14
Is there a question in there some place?

Report •

October 28, 2009 at 08:43:34
Yes. I'm interested in an Excel macro to do all of this.

Report •

October 28, 2009 at 09:52:11
Oh, I see.

Typically, the etiquette followed in this forum (and most others) is to actually ask for assistance as opposed to just announcing a set or requirements and expecting people to supply a solution. People want to help, but posts come across as sort of arrogant when all they do is read like a list of demands. I'm sure you didn't mean to have it sound that way, but it does.

That said, and since we don't know your level of expertise in VBA, I'll offer this as a starting point:

Sub WhatUser()
 curUser = Application.UserName
End Sub

This will set curUser to the UserName of the person logged into the machine at the time that the macro is run.

The current UserName could be compared to a list of allowed UserNames, perhaps stored in a hidden sheet, and if found, the sheet to be edited could be unprotected and then protected again when saved.

Obviously, the code module that contained the Password to unprotect the sheet would have to be hidden and password protected also.

Let us know if you need any further assistance.

Report •

Related Solutions

October 28, 2009 at 10:00:33
First time user, and far from arrogant. Thanks for the advise, and suggested solution.

Report •

October 28, 2009 at 10:14:20
re: far from arrogant

I thought so! :)

I just played with this under my own UserName and it did indeed unprotect Sheet1:

Sub UnProtectByUser()
 With Sheets(2).Range("A1:A10")
  Set c = .Find(Application.UserName, LookIn:=xlValues)
    If Not c Is Nothing Then
        Sheets(1).Unprotect Password:="pw"
    End If
 End With
End Sub

Protecting the sheet could be done with a BeforeSave macro.

Report •

Ask Question