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
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