Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VBA to lock column values

Hi,

I would like to be able to use a subroutine to lock cells in columns that
have column headers of specific dates. In this sittuation, I have quarterly
dates interjected between monthly dates in the cells in the row that serves
as the column headers. For the columns that have a header of a monthly date,
say "Jul-2009", I would like the cells in a certain range of that column say
row 8 through row 11 to be unlocked, and for a columns that have a header of
a quarterly date, say "Q2-2009", I would like the cells in that range (rows
8-11) to be locked.

Any thoughts?

Thanks!
--
Hugo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA to lock column values

If those "date" values are simply text, you may be able to use something like:

Option Explicit
Sub testme()
Dim myCell As Range
Dim myHeader As Range

With Worksheets("sheet1")
.unprotect password:="topsecret"

Set myHeader = .Range("A1", .Cells(1, .Columns.Count).End(xlToLeft))

For Each myCell In myHeader.Cells
If LCase(myCell.Value) Like "q#-####" Then
Intersect(myCell.EntireColumn, .Rows(8).Resize(4)).Locked = True
ElseIf LCase(myCell.Value) Like "???-####" Then
Intersect(myCell.EntireColumn, .Rows(8).Resize(4)).Locked = False
End If
Next myCell

.protect password:="topsecret"
End With
End Sub





Hugo wrote:

Hi,

I would like to be able to use a subroutine to lock cells in columns that
have column headers of specific dates. In this sittuation, I have quarterly
dates interjected between monthly dates in the cells in the row that serves
as the column headers. For the columns that have a header of a monthly date,
say "Jul-2009", I would like the cells in a certain range of that column say
row 8 through row 11 to be unlocked, and for a columns that have a header of
a quarterly date, say "Q2-2009", I would like the cells in that range (rows
8-11) to be locked.

Any thoughts?

Thanks!
--
Hugo


--

Dave Peterson
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
Lock Axis Values? Ryan Charts and Charting in Excel 4 April 22nd 23 09:01 AM
Any way to Lock format but not the values? lbbss Excel Discussion (Misc queries) 9 November 20th 08 03:02 AM
How do I lock cell value even if other values change Loraise Excel Discussion (Misc queries) 1 December 19th 06 09:24 AM
how do I lock values in excel nupe1493 Excel Worksheet Functions 1 June 15th 06 06:55 PM
Lock cells for combo box values only Daniel Excel Programming 4 December 28th 05 07:22 PM


All times are GMT +1. The time now is 07:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"