Hello!
I am fairly new to this level of excel and any constructive applicable help is greatly appreciated! I am trying to create a form, that once the row is completed, it will create a new blank row, but which contains all the formulas of the previous row.
My form, has date formatting, totals and percentages.
[TABLE="width: 1048"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]RECEIPT/[/TD]
[TD]TOTAL[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]RETAILER/[/TD]
[TD]ATTACHED[/TD]
[TD] CLAIM[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DATE[/TD]
[TD]DESCRIPTION[/TD]
[TD]JOB REF[/TD]
[TD]SUPPLIER[/TD]
[TD]Y/N[/TD]
[TD] AMOUNT[/TD]
[TD]VAT[/TD]
[TD] NET[/TD]
[/TR]
[TR]
[TD]Mon 10 August 2015[/TD]
[TD]Diesal[/TD]
[TD]Phillips[/TD]
[TD]Moto[/TD]
[TD]Y[/TD]
[TD]£45.00[/TD]
[TD]£7.49[/TD]
[TD]£37.51[/TD]
[/TR]
[TR]
[TD]Sat 15 August 2015[/TD]
[TD]Toll[/TD]
[TD]Heath[/TD]
[TD]Bridge[/TD]
[TD]Y[/TD]
[TD]£12.80[/TD]
[TD]£2.13[/TD]
[TD]£10.67[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] Total[/TD]
[TD] Total[/TD]
[TD] Total[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£57.80[/TD]
[TD]£9.62[/TD]
[TD]£48.18[/TD]
[/TR]
</tbody>[/TABLE]
I am struggling to configure a way that can process all of it at once, without overlapping the totals or effecting other cells the wrong way.
I have tried researching it and added and edited codes within the worksheet, but I run into errors and name problems.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = [TotalVal].Row - 1 Then
Application.EnableEvents = False
[TotalVal].EntireRow.Insert
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
Dim rDelete As Range
If Not Intersect(Target, Range("TotalVal").EntireColumn) Is Nothing Then
Application.EnableEvents = False
For Each rCell In Intersect(Target, Range("TotalVal").EntireColumn).Cells
If rCell.Row = Range("TotalVal").Row - 1 Then
If Len(rCell.Value) > 0 Then
Range("TotalVal").EntireRow.Insert
Else
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
ElseIf Len(rCell.Value) = 0 Then
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
Application.EnableEvents = True
End If
End Sub
That is what I have so far. It does add a new row, but does not copy the previous rows formulae, percentages etc and does not automatically delete unwanted rows.
I ideally want my form to look like this:
[TABLE="width: 1048"]
<tbody>[TR]
[TD]RECEIPT/[/TD]
[TD]TOTAL[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]RETAILER/[/TD]
[TD]ATTACHED[/TD]
[TD] CLAIM[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DATE[/TD]
[TD]DESCRIPTION[/TD]
[TD]JOB REF[/TD]
[TD]SUPPLIER[/TD]
[TD]Y/N[/TD]
[TD] AMOUNT[/TD]
[TD]VAT[/TD]
[TD] NET[/TD]
[/TR]
[TR]
[TD]Mon 10 August 2015[/TD]
[TD]Diesal[/TD]
[TD]Phillips[/TD]
[TD]Moto[/TD]
[TD]Y[/TD]
[TD]£45.00[/TD]
[TD]£7.49[/TD]
[TD]£37.51[/TD]
[/TR]
[TR]
[TD]Sat 15 August 2015[/TD]
[TD]Toll[/TD]
[TD]Heath[/TD]
[TD]Bridge[/TD]
[TD]Y[/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
</tbody>[/TABLE]
Total Total Total
£45.00 £7.49 £37.51
[TABLE="width: 1048"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
And then when I fill out and complete another row of data, it automatically adds another blank row, with each column formatted, but the totals are unaffected by this and still only produce the totals.
I hope I've made enough sense, please fire questions if I haven't. I would be tremendously grateful for someone to explain to me what I am doing wrong and how I should be going about this.
HUGE THANKS!
I am fairly new to this level of excel and any constructive applicable help is greatly appreciated! I am trying to create a form, that once the row is completed, it will create a new blank row, but which contains all the formulas of the previous row.
My form, has date formatting, totals and percentages.
[TABLE="width: 1048"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]RECEIPT/[/TD]
[TD]TOTAL[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]RETAILER/[/TD]
[TD]ATTACHED[/TD]
[TD] CLAIM[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DATE[/TD]
[TD]DESCRIPTION[/TD]
[TD]JOB REF[/TD]
[TD]SUPPLIER[/TD]
[TD]Y/N[/TD]
[TD] AMOUNT[/TD]
[TD]VAT[/TD]
[TD] NET[/TD]
[/TR]
[TR]
[TD]Mon 10 August 2015[/TD]
[TD]Diesal[/TD]
[TD]Phillips[/TD]
[TD]Moto[/TD]
[TD]Y[/TD]
[TD]£45.00[/TD]
[TD]£7.49[/TD]
[TD]£37.51[/TD]
[/TR]
[TR]
[TD]Sat 15 August 2015[/TD]
[TD]Toll[/TD]
[TD]Heath[/TD]
[TD]Bridge[/TD]
[TD]Y[/TD]
[TD]£12.80[/TD]
[TD]£2.13[/TD]
[TD]£10.67[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] Total[/TD]
[TD] Total[/TD]
[TD] Total[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£57.80[/TD]
[TD]£9.62[/TD]
[TD]£48.18[/TD]
[/TR]
</tbody>[/TABLE]
I am struggling to configure a way that can process all of it at once, without overlapping the totals or effecting other cells the wrong way.
I have tried researching it and added and edited codes within the worksheet, but I run into errors and name problems.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = [TotalVal].Row - 1 Then
Application.EnableEvents = False
[TotalVal].EntireRow.Insert
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
Dim rDelete As Range
If Not Intersect(Target, Range("TotalVal").EntireColumn) Is Nothing Then
Application.EnableEvents = False
For Each rCell In Intersect(Target, Range("TotalVal").EntireColumn).Cells
If rCell.Row = Range("TotalVal").Row - 1 Then
If Len(rCell.Value) > 0 Then
Range("TotalVal").EntireRow.Insert
Else
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
ElseIf Len(rCell.Value) = 0 Then
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
Application.EnableEvents = True
End If
End Sub
That is what I have so far. It does add a new row, but does not copy the previous rows formulae, percentages etc and does not automatically delete unwanted rows.
I ideally want my form to look like this:
[TABLE="width: 1048"]
<tbody>[TR]
[TD]RECEIPT/[/TD]
[TD]TOTAL[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]RETAILER/[/TD]
[TD]ATTACHED[/TD]
[TD] CLAIM[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DATE[/TD]
[TD]DESCRIPTION[/TD]
[TD]JOB REF[/TD]
[TD]SUPPLIER[/TD]
[TD]Y/N[/TD]
[TD] AMOUNT[/TD]
[TD]VAT[/TD]
[TD] NET[/TD]
[/TR]
[TR]
[TD]Mon 10 August 2015[/TD]
[TD]Diesal[/TD]
[TD]Phillips[/TD]
[TD]Moto[/TD]
[TD]Y[/TD]
[TD]£45.00[/TD]
[TD]£7.49[/TD]
[TD]£37.51[/TD]
[/TR]
[TR]
[TD]Sat 15 August 2015[/TD]
[TD]Toll[/TD]
[TD]Heath[/TD]
[TD]Bridge[/TD]
[TD]Y[/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[TD]£0.00[/TD]
[/TR]
</tbody>[/TABLE]
Total Total Total
£45.00 £7.49 £37.51
[TABLE="width: 1048"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
And then when I fill out and complete another row of data, it automatically adds another blank row, with each column formatted, but the totals are unaffected by this and still only produce the totals.
I hope I've made enough sense, please fire questions if I haven't. I would be tremendously grateful for someone to explain to me what I am doing wrong and how I should be going about this.
HUGE THANKS!