How about add the formula in column C when the user puts something in column A.
Then you could remove all those "reserved" formulas.
If you want to try it...
rightclick on the worksheet tab that should have this behavior and select view
code. Paste this into the code window:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub 'one cell at a time
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub
Application.EnableEvents = False
On Error GoTo errHandler:
If IsEmpty(Target) Then
Me.Cells(Target.Row, "C").ClearContents
Else
With Me.Cells(Target.Row, "C")
'.FormulaR1C1 = "=IF(RC[-2]="""","""",RC[-2]+1-WEEKDAY(RC[-2]+8-2))"
.FormulaR1C1 = "=RC[-2]+1-WEEKDAY(RC[-2]+8-2)"
.NumberFormat = "mm/dd/yyyy"
End With
End If
errHandler:
Application.EnableEvents = True
End Sub
If you clear the contents of the cell in column A, the code will clean up column
C. So the formula could be made a bit simpler. (I commented out the
original--you can still use that if you want. Just delete the shorter version.)
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
JulesM wrote:
>
> Ah..Ok..the penny drops. I think I know what I'm doing to cause this.
>
> To explain, at it's simplest my sheet looks like this:
>
> Column A = Date
> Column B = Some data
> Column C = formula to calculate the Week Commencing date of the value
> supplied in Column A
>
> So....in order to ensure that the week commencing date column would
> automatically be populated I copied the formula into the entire column
> C.
>
> =IF(A1="","",A1+1-WEEKDAY(A1+8-2))
>
> (the IF statement was purely to stop a cell full of ##### being
> returned when the vaule in column A was not set - beacuse no data had
> yet been entered here).
>
> I want users to be able to pull back data just for one week at a time
> using the auto filter on column C. But now I think I understand that
> because the formula fills the entire column the filter is applied to
> the entire column and then leaves no free rows to input data. Sound
> feasible?
>
> Firstly - is there a better way (than pasting formula into entire
> column) to be sure that the value in column C will always be
> calculated?
>
> Secondly - Is there something clever I can do with (auto) filter to
> only filter on rows in Column C where a value is returned OR filter
> only on rows where column A contains a value?
>
> Many thanks for your response.
> Jules
>
> --
> JulesM
> ------------------------------------------------------------------------
> JulesM's Profile: http://www.excelforum.com/member.php...o&userid=27609
> View this thread: http://www.excelforum.com/showthread...hreadid=471715
--
Dave Peterson