Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 48
Default Cell change, reset formula?

(also posted in Programming)

I have a situation in Excel where I want to restore the formula in a cell in
case of damage. I want to do this because for various reasons I cannot use
standard sheet protection. Also, I'm not really familiar with VBA
programming so I'm really struggeling and getting very little sleep these
nights.....

If you have time, please take a look at my problem and give me some hints,
even if it's just to tell me it's not possible....

I've implemented the following code, restoring formula =C - D if target is
within my "protectarea" (e.g. "E:E"):

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rr As Long
If Not Intersect(Target, Range("Protectarea")) Is Nothing Then
rr = Target.Row
Application.EnableEvents = False
Target.Formula = "=C" & rr & " - " & "D" & rr
Application.EnableEvents = True
End If
End Sub

This works fine until I change multiple cells in a range that partly overlap
my "protect area". In such case all cells will of course be changed according
to formula, even though I just want to manipulate those in "protect area".

q1. Is there any way to solve this?

q2. If not, can I prevent the user to even select the cells in Protectarea?
This would actually be a better solution. Is it possible to achive this in
worksheet_selectionchange()? I'm thinking similar to sheetprotection with not
being able to select locked cells, only with sheetprotection switched off
(confused...?).
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Cell change, reset formula?

You are very welcome. Post whenever you hit a roadblock
--
Gary''s Student
gsnu200712

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Cell change, reset formula?

The problem is that you are applying the formula to target:
Target.Formula="=C" & rr & " - " & "D" & rr
How about restricting it to:
Intersect(Target, Range("Protectarea")) .Formula="=C" & rr & " - " & "D" & rr
--
Gary''s Student
gsnu200712

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 48
Default Cell change, reset formula?

You're so right. This is exactly what I want and need.. The problem is I
don't know anything about VBA programming, I'm actually a doctor - working
with humans - not computers. Still I'm trying to do a lot of "advanced stuff"
in Excel these days.. Guess I'm learning by doing.... I'm really glad the
discussions pages exits though, otherwise I would have been lost..

Thank you
Kathrine

"Gary''s Student" wrote:

The problem is that you are applying the formula to target:
Target.Formula="=C" & rr & " - " & "D" & rr
How about restricting it to:
Intersect(Target, Range("Protectarea")) .Formula="=C" & rr & " - " & "D" & rr
--
Gary''s Student
gsnu200712

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
Set cell to record date when adjacent cell is filled AND NOT RESET The new guy Excel Worksheet Functions 3 February 26th 07 06:11 PM
Way to reset the last cell to be EOF Mary Barnich-Tampa Excel Discussion (Misc queries) 2 June 19th 06 06:02 PM
How do I reset the last cell of a worksheet? VLP Excel Discussion (Misc queries) 4 April 18th 06 04:10 PM
Because of row/column deletions, how do you reset the last cell? AndreaW Excel Discussion (Misc queries) 3 March 23rd 06 06:13 PM
how do you reset your arrow keys to move cell to cell? Marchelle New Users to Excel 1 May 13th 05 10:37 PM


All times are GMT +1. The time now is 07:37 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"