prefill columns possibly via formula

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
Office Version
  1. 365
Platform
  1. Windows
hi
when i add row it prefills based on formulas and other data
i want to add an additional peice of formula or data
my table now add row adds columns A-AL
column AG is prefilled with formula today
i have a saved data range that can potentially override as you see DefaultDeductDate

how do i add that in the add row module that if DefaultDeductDate is <> today then DefaultDeductDate else blank

Rich (BB code):
Sub AddNewRow()
 
    Dim DefaultDeductDate            As String
    
    DefaultDeductDate = Worksheets("PrintSettings").Range("Default_Deduct_Date")

    Call WSUnProtect(Worksheets("Bills"))
    Dim tbl As ListObject, LastRow As Range
    Dim col As Long
    Set tbl = Worksheets("Bills").ListObjects("Bills")
    
    'First check if the last row is empty; if not, add a row
    If tbl.ListRows.Count > 0 Then
        Set LastRow = tbl.ListRows(tbl.ListRows.Count).Range
        For col = 1 To LastRow.Columns.Count
            If Trim(CStr(LastRow.Cells(1, col).Value)) <> "" Then
                tbl.ListRows.Add AlwaysInsert:=True
                Exit For
            End If
        Next col
    Else
        tbl.ListRows.Add AlwaysInsert:=True
    End If
    
  probably i need to add the If over here but i am not sure how to do that
    

    Call WSProtect(Worksheets("Bills"))
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You need to say what the contents of AG are ... you say it is a formula, but you don't say what it is. Also, what are the contents of Worksheets("PrintSettings").Range("Default_Deduct_Date")?
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,218
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top