![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Is there a way to lock cells using VB based on the value of another cell. Example:
IF A2 = A1 then Locked Cells C2 and D2 from data entry. Thanks. |
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Put this macro in the sheet's module.
Private Sub Worksheet_Calculate() If [A2] = [A1] Then [C2:D2].Locked = True Else [C2:D2].Locked = False End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|