Solved

Password Protect Individual Columns in Excel w/ VBA

Posted on 2013-11-22
11
1,781 Views
Last Modified: 2013-11-22
Is there a way to password protect active cell individual columns with VBA?
0
Comment
Question by:mattfmiller
  • 6
  • 3
  • 2
11 Comments
 
LVL 4

Expert Comment

by:yuppydu
ID: 39669340
No, as far as I know you cannot password protect one cell or one column
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39669355
Sure you can. The sheet must be protected but if you do this but by default only things that are locked will be effected, so then do this.

    Columns("C:C").Select
    Selection.Locked = True

Open in new window

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39669361
Actually there's no need to Select, so...
    Columns("C:C").Locked = True

Open in new window

0
 
LVL 4

Expert Comment

by:yuppydu
ID: 39669391
Martin that locks it, but can you password protect it as Matt asked? I do not know of way for doing that
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39669413
    With ActiveSheet
        .Columns("C:C").Locked = True
        .Protect Password:="My password"
    End With

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:mattfmiller
ID: 39669439
Is there a way to password protect a relative reference?
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39669672
Is there a way to password protect a relative reference?
Please give me an example of what you mean.
0
 
LVL 1

Author Comment

by:mattfmiller
ID: 39669689
For example

Do while ActiveCell.value = "" = false
If Activecell.interior.color = red then
Protect column
End if

ActiveCell.offset(1,0).select



Loop
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39669719
I'm not sure what you mean here Do while ActiveCell.value = "" = false but this should work for the rest

    With ActiveSheet
        If ActiveCell.Interior.Color = vbRed Then
            .Columns(ActiveCell.Column).Locked = True
            .Protect Password:="My password"
        End If
    End With

Open in new window

0
 
LVL 1

Author Comment

by:mattfmiller
ID: 39670252
Thx.  I ended up going with with

ActiveCell.Columns("A:A").EntireColumn.Locked = True

then closing the loop with the ActiveSheet.protect.

The password I will incorporate into my macro (Didn't know you could do that)
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39670287
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now