Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help locking column on date value

Hi,
I want to lock/protect column of a particular date once the date changes. I tried doing it with different vba codes but no use. Eg. if the date is 25th October,2004,
the column with the same date should get locked/protected once the date system date changes.
Thanks in advance for your help.

Shobhit Bhatnagar

Date 10/1 10/2 10/3 10/4 10/5 10/6 10/7 10/8 10/9 10/10 10/11 10/12 10/13 10/14

Parameters
a
b
c
d
e
f

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help locking column on date value

Private Sub Workbook_Open()
Dim cell as Range
Worksheets("Schedule").Activate
for each cell in Rows(1).Cells
if cell.Text = Format(date,"mm/d")
activeSheet.Unprotect
cell.EntireColumn.Locked = True
activeSheet.Protect
exit for
end if
Next
End Sub

Put this is in the workbook.open event
[Chip Pearson's page on events - http://www.cpearson.com/excel/events.htm]

See help on the protect and unprotect methods for arguments (like password).

--
Regards,
Tom Ogilvy


"Shobhit Bhatnagar" wrote in message
...
Hi,
I want to lock/protect column of a particular date once the date changes. I
tried doing it with different vba codes but no use. Eg. if the date is 25th
October,2004,
the column with the same date should get locked/protected once the date
system date changes.
Thanks in advance for your help.

Shobhit Bhatnagar

Date10/110/210/310/410/510/610/710/810/910/1010/1110/1210/1310/14

Parameters
a
b
c
d
e
f


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help locking column on date value

Thanks for your reply. I tried the code it does not work. What i am
trying to achive is to protect the column based on the date value. The
columns which are less than current system date should get protected.
Through this code i tried to the whole sheet get protected.

Thanks for the solution in advance.

Shobhit Bhatnagar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help locking column on date value

You need to understand protection. Cells are locked or unlocked - which is
meaningless unless the sheet it protected.

--
Regards,
Tom Ogilvy

"Shobhit Bhatnagar" wrote in message
...
Thanks for your reply. I tried the code it does not work. What i am
trying to achive is to protect the column based on the date value. The
columns which are less than current system date should get protected.
Through this code i tried to the whole sheet get protected.

Thanks for the solution in advance.

Shobhit Bhatnagar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help locking column on date value

Thanks Tom,
A bit of tweaking with your code now it works.

Private Sub Workbook_Open()
Dim cell As Range
Worksheets("Sheet1").Activate
ActiveSheet.Unprotect Password:="abc"
For Each cell In Rows(1).Cells
If cell.Text < Format(Date, "dd/mm/yyyy") Then
cell.EntireColumn.Locked = True
Else
cell.EntireColumn.Locked = False
End If
Next
ActiveSheet.Protect Password:="abc"
End Sub

Thanks



"Tom Ogilvy" wrote in message
...
You need to understand protection. Cells are locked or unlocked - which

is
meaningless unless the sheet it protected.

--
Regards,
Tom Ogilvy

"Shobhit Bhatnagar" wrote in message
...
Thanks for your reply. I tried the code it does not work. What i am
trying to achive is to protect the column based on the date value. The
columns which are less than current system date should get protected.
Through this code i tried to the whole sheet get protected.

Thanks for the solution in advance.

Shobhit Bhatnagar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!







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
Locking column headers Fatwilly Excel Discussion (Misc queries) 1 July 29th 08 09:43 PM
Locking Formula - Whole Column Schwimms Excel Discussion (Misc queries) 3 March 10th 08 09:13 PM
Locking a Column SiH23 Excel Discussion (Misc queries) 4 October 23rd 07 07:56 PM
Locking column entries to an adjacent linked column Steeljaw Excel Discussion (Misc queries) 1 January 23rd 06 10:45 PM
Locking column LSB Excel Programming 1 July 28th 03 10:03 AM


All times are GMT +1. The time now is 10:19 PM.

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

About Us

"It's about Microsoft Excel"