Excel/To remove formula

Advertisement


Question
In my Excel workbook, 14 columns are there C to P with range C1:P200 Row 1 contains time value. Example: C1=9/27/2014 8:42:34 AM; D1=9/27/2014 9:12:25 AM & so on...till P1.

Output required: C2:C200 should become FORMULA FREE IMMEDIATELY & leave the value when system's time>=C1 Similarly, D2:200 should become FORMULA FREE & leave the value when system's time>=D1 & so on till column P i.e. P2:P200 should become FORMULA FREE & leave the value when system's time>=P1
The code would be pasted in a ws with tab named 'F24' of my Excel workbook. There are 2 more ws in the Excel workbook with tab named 'A4' & '7'. 'A4' contains code as Worksheet event code & '7' updates using real time feeds. Note: The new code in 'F24' should not affect working of either of 'A4' or '7'

Answer
I supposed you could use a Worksheet_Calculate event...   This triggers anytime a formula updates on a worksheet.  After all the calculations are done the event triggers and we could have check all the columns with formulas in them and compare the system time to the times listed in row1 and remove the formulas in any column with a time that has passed.


Option Explicit

Private Sub Worksheet_Calculate()
Dim cell As Range

On Error Resume Next
Application.EnableEvents = False

For Each cell In Range("C2:P2").SpecialCells(xlFormulas)
    If Cells(1, cell.Row) <= Now Then
        With cell.Resize(199)
            .Value = .Value
        End With
    End If
Next cell

Application.EnableEvents = True
End Sub

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Jerry Beaucaire

Expertise

Excel Formulas, macros, automation. Microsoft Excel MVP - 2010. Code site with free code snippets and techniques: http://sites.madrocketscientist.com/jerrybeaucaires-excelassistant/files

Experience

Microsoft Excel MVP - 2010. I have my own extensive Excel help/code site: http://sites.madrocketscientist.com/jerrybeaucaires-excelassistant/files ===================== I have been offering free assistance as an Excel aid on many web sites for many years: (http://www.excelforum.com - JBeaucaire) ======== (http://www.askmehelpdesk.com/spreadsheets - JBeaucaire) ======= (http://www.mrexcel.com/forum - jbeaucaire)

Education/Credentials
Bachelor's Degree from Azusa Pacific University in Mathematics and Music Composition

Awards and Honors
Microsoft Excel MVP 2010

©2016 About.com. All rights reserved.