Hi I have below code.
Sub sixsheet()
Dim rng, r As Range
With Worksheets("06sheet")
Const n As Long = 5 ' Last number to be changed if nuber of top records to be changed
Set r = .Cells.Find("*", .Cells(Rows.Count, Columns.Count))
If r Is Nothing Then MsgBox "No data": Exit Sub
Set rng = .Range(r, .Cells(Rows.Count, r.Column).End(xlUp))
With rng.Resize(n + 1)
Union(.Columns(1), .Columns(3)).Copy r.End(xlToRight)(, 2)
End With
With r.End(xlToRight)(n + 2).Resize(, 3) 'Change the last number "3" to change the sum calculation field.
.FormulaR1C1 = "=sum(r" & r.Row + 1 & "c:r[-1]c)"
.Font.Bold = True
End With
With r.End(xlToRight)(, 2).Resize(, 2)
.Cells(, 0).Copy .Cells
.Value = [{"SOW"}]
.Cells(2, 1).Resize(n).FormulaR1C1 = "=rc[-1]/r" & r.Row + n + 1 & "c[-1]"
.Cells(2, 1).Resize(n + 1).NumberFormat = "#0.00%"
End With
With r.End(xlToRight)(, 1).Resize(, 1)
.Cells(, 0).Copy .Cells
.Value = [{"No of claims (%)"}]
.Cells(2, 1).Resize(n).FormulaR1C1 = "=rc[-5]/r" & r.Row + n + 1 & "c[-5]"
.Cells(2, 1).Resize(n + 1).NumberFormat = "#0.00%"
End With
.Columns("A:I").AutoFit
End With
End Sub
In above code in last created Column H, I wanted to change the cell number of total value
At present the valuse of C divided by cell C12. But I wanted to Change the code where Cell c12 to be the last of the Column C.
For formula example refere sheet "Result" Column H.
Bookmarks