Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Password Protect Individual Columns in Excel w/ VBA

Posted on 2013-11-22
11
Medium Priority
?
2,161 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 49

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 49

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 49

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
 
LVL 1

Author Comment

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

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 49

Accepted Solution

by:
Martin Liss earned 2000 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 49

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

916 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