Results 1 to 2 of 2

Macro To Add Formula When New Row Added

Threaded View

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    Worcester
    MS-Off Ver
    Microsoft 365
    Posts
    19

    Macro To Add Formula When New Row Added

    Hello,

    I need some help with a Macro to add a formula to the first column of a table when a new row is added. The rows are added automatically when a Microsoft form is submitted. This is what I have....

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        Dim tbl As ListObject
        Dim newRow As ListRow
            
        Set tbl = ActiveSheet.ListObjects(1)
        
    If Target.Address = tbl.ListColumns(1).DataBodyRange.Cells(tbl.ListRows.Count).Address Then
            Set newRow = tbl.ListRows.Add
            newRow.Range.Cells(1, 1).Formula = "=IF(TODAY()>Defects[28 Day Deadline],""Past SLA"",""Open"")"
        End If
    
    End Sub
    Any help greatly appreciated!
    Last edited by alansidman; 02-03-2024 at 10:34 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Add formula to one sheet when a new sheet is added to workbook - Macro
    By Lazarus Rises in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-03-2021, 06:23 PM
  2. Formula does not work when added to macro
    By tsnipes in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-27-2015, 06:15 PM
  3. Replies: 2
    Last Post: 04-15-2015, 05:33 PM
  4. Inserting a formula using vba or macro in a new row when new product is added
    By Spreadlover in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-30-2013, 05:36 PM
  5. Replies: 6
    Last Post: 08-18-2011, 05:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1