![]() |
![]() |
|
|||||||
| 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 |
|
New Member
Join Date: Feb 2002
Posts: 3
|
Is there a way to lock cells using VB based on the value of another cell. Example:
I have a list for data entry, if the value of the first cell in the row (A2)is equal to the value of the first row (A1) then I want to lock Cells C2 and D2. This will apply for all subsequent rows as data is entered. What is the best way of doing this? Thanks. |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
You may be able to use data validation for this. Go to your cell you want to lock, and choose validation from the data menu. On the setting tab, change the allow drop down to custom. Type in =A2<>A1 under the formula. You can also add custom input and error messages here if you choose.
Be aware that this will prevent a user from typing in a value if A1=A2, but it will not prevent a user from pasting a value here. If you need something more robust, VBA is needed. Good luck. Quote:
|
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Did you see my reply to your other post ?
|
|
|
|
|
|
#4 | |
|
New Member
Join Date: Feb 2002
Posts: 3
|
Quote:
Thanks. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|