Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following code locks data onto column IV. So whenever a column elsewhere
is deleted the data will not shift to IU. Private Sub Worksheet_Change(ByVal Target As Range) Const fixed_name = "lock_formula" Const refer_str = "=Sheet1!$IV$1:$IV$800" Dim rng As Range Dim save_formula If IsError(Evaluate(fixed_name)) Then ActiveWorkbook.Names.Add Name:=CStr(fixed_name), RefersTo:=CStr(refer_str) Else If CStr(ActiveWorkbook.Names(CStr(fixed_name)).Refers To) < CStr(refer_str) Then On Error GoTo CleanUp Application.EnableEvents = False Set rng = Evaluate(fixed_name) save_formula = rng.Formula rng.Value = "" Set rng = Range(CStr(refer_str)) rng.Formula = save_formula ActiveWorkbook.Names(CStr(fixed_name)).RefersTo = CStr(refer_str) Else 'do nothing End If End If CleanUp: Application.EnableEvents = True End Sub What if I want to add a column somewhere on the sheet? I could first delete an unused column somewhere on the sheet, but because the code behind the sheet is to prevent the shift of data to field IU I am therefore unable to add a new column/field. How can I retain the code but also allow the addition of a new column/field? Thanks if you are able to help. Pat |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding Text to Calculated Field | Excel Worksheet Functions | |||
Adding two field into Pivot Table | Excel Discussion (Misc queries) | |||
Adding a hylerlink to a text field | Excel Discussion (Misc queries) | |||
Adding a Background to a date in a field | Excel Discussion (Misc queries) | |||
Adding spaces to a text field | Excel Programming |