ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Locking specific cells (https://www.excelbanter.com/excel-programming/438886-locking-specific-cells.html)

Eddy Stan

Locking specific cells
 
HI
i posted a query already - please ignore that.

In a data entry sheet
column b has dates and B3 has specific date
i like to lock adjacent cells in columns F,G & H
if the date in column B is not date in B3 (criteria)
further should not allow to delete anyrow when there is value in cells of
F,G & H columns. if there is no value then those can be deleted.

sub Worksheet_Change(ByVal Target As Range)

if cell(b column) = $B$3 then
activesheet.unprotect ="hi"
cell.("F"&row).locked = false
cell.("G"&row).locked = false
cell.("h"&row).locked = false

else
activesheet.unprotect ="hi"
cell.("F"&row).locked = true
cell.("G"&row).locked = true
cell.("h"&row).locked = true
endif

activesheet.protect ="hi"

end sub







Ryan H

Locking specific cells
 
Did I fix this issue for you in your other post titled "CAN WE LOCK CELLS AT
F COLUMN BASED ON VALUE AT C COLUMN" or is this a new issue?

--
Cheers,
Ryan


"Eddy Stan" wrote:

HI
i posted a query already - please ignore that.

In a data entry sheet
column b has dates and B3 has specific date
i like to lock adjacent cells in columns F,G & H
if the date in column B is not date in B3 (criteria)
further should not allow to delete anyrow when there is value in cells of
F,G & H columns. if there is no value then those can be deleted.

sub Worksheet_Change(ByVal Target As Range)

if cell(b column) = $B$3 then
activesheet.unprotect ="hi"
cell.("F"&row).locked = false
cell.("G"&row).locked = false
cell.("h"&row).locked = false

else
activesheet.unprotect ="hi"
cell.("F"&row).locked = true
cell.("G"&row).locked = true
cell.("h"&row).locked = true
endif

activesheet.protect ="hi"

end sub








All times are GMT +1. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com