Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default formating cells from IF statement

I want to protect a given cell if the contents of another cell is "Conf". I
can record a macro to Format-Cell-Protection-Locked, but how do I combine
that with the conditional IF? Thanks very much!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default formating cells from IF statement

I don't believe you can protect just one cell the way you described. You
have to protect the entire sheet and then unlock those cells that you want to
allow editing in.

"Anner" wrote:

I want to protect a given cell if the contents of another cell is "Conf". I
can record a macro to Format-Cell-Protection-Locked, but how do I combine
that with the conditional IF? Thanks very much!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default formating cells from IF statement

Here is a different approach for you to consider. You didn't tells us
anything about your layout, so I made the assumption that A1 was the cell
you wanted protected if C3 contained the text "Conf" (change them to the
cells you are actually using. Put this code in the worksheet's code window
(right click that worksheet's tab and select View Code)...

'***************** START OF CODE *****************
Dim OldValue As Variant

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("C3").Value = "Conf" And Target.Address = "$A$1" Then
On Error GoTo Done
Application.EnableEvents = False
MsgBox "That cell cannot be changed if A1 equals ""Conf""!"
Target.Value = OldValue
Target.Select
Else
'
' Your Change event code, if any, goes here
'
End If
Done:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then OldValue = Target.Value
'
' Your SelectionChange event code, if any, goes here
'
End Sub
'***************** END OF CODE *****************

--
Rick (MVP - Excel)


"Anner" wrote in message
...
I want to protect a given cell if the contents of another cell is "Conf".
I
can record a macro to Format-Cell-Protection-Locked, but how do I
combine
that with the conditional IF? Thanks very much!


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
Formating Cells Untiedfullfillment Excel Discussion (Misc queries) 2 October 11th 06 02:28 PM
conditional formating cells i Excel based on other cells values Elias Petursson Excel Worksheet Functions 3 May 23rd 06 06:45 PM
Conditional formating on if statement SCOOBYDOO Excel Worksheet Functions 2 November 30th 05 06:58 PM
Flat File formating with Print# Statement Mike Field Excel Programming 1 December 4th 03 04:22 PM
formating a cell with a conditional if statement Rich[_11_] Excel Programming 1 July 14th 03 09:00 PM


All times are GMT +1. The time now is 11:48 AM.

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"