Hi,
Apologies in advance if there is an answer to this somewhere, I have spent hours searching google and can't find anything that solves my issue!
I have a VBA (below) which I run as an add-on when excel opens. Every time Excel opens it tells me there is a circular reference related to the VBA in Sheet1!$P$2. I am guessing the error is from Range("P" & LastRow + 1).Formula = "=SUM(P2:P" & LastRow & ")" however I got this line of code from a solution someone posted which apparently worked quite well for them. The VBA functions properly but the error message is annoying and I'm thinking (hoping) it is a simple fix?
Thanks in advance
Sub BaxterSum()
Dim ws As Worksheet
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
Columns(16).NumberFormat = "General"
Columns(18).NumberFormat = "General"
'Delete Blank Rows
On Error Resume Next
Range("O1:O1000").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
LastRow = Range("G" & Rows.Count).End(xlUp).Row
Range("O" & LastRow + 1) = "Total"
Range("P" & LastRow + 1).Formula = "=SUM(P2:P" & LastRow & ")"
'Enter formula for fuel surcharge (last number is fuel surcharge as a decimal)
Range("R" & LastRow + 1).Formula = "=(Q" & LastRow + 1 & ")*.046"
'Colour Last Row
Range(Cells(LastRow + 1, "O"), Cells(LastRow + 1, "P")).Interior.ColorIndex = 3
'Freeze top row
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
.FreezePanes = True
End With
Next ws
End Sub
Apologies in advance if there is an answer to this somewhere, I have spent hours searching google and can't find anything that solves my issue!
I have a VBA (below) which I run as an add-on when excel opens. Every time Excel opens it tells me there is a circular reference related to the VBA in Sheet1!$P$2. I am guessing the error is from Range("P" & LastRow + 1).Formula = "=SUM(P2:P" & LastRow & ")" however I got this line of code from a solution someone posted which apparently worked quite well for them. The VBA functions properly but the error message is annoying and I'm thinking (hoping) it is a simple fix?
Thanks in advance
Sub BaxterSum()
Dim ws As Worksheet
Dim LastRow As Long
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
Columns(16).NumberFormat = "General"
Columns(18).NumberFormat = "General"
'Delete Blank Rows
On Error Resume Next
Range("O1:O1000").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
LastRow = Range("G" & Rows.Count).End(xlUp).Row
Range("O" & LastRow + 1) = "Total"
Range("P" & LastRow + 1).Formula = "=SUM(P2:P" & LastRow & ")"
'Enter formula for fuel surcharge (last number is fuel surcharge as a decimal)
Range("R" & LastRow + 1).Formula = "=(Q" & LastRow + 1 & ")*.046"
'Colour Last Row
Range(Cells(LastRow + 1, "O"), Cells(LastRow + 1, "P")).Interior.ColorIndex = 3
'Freeze top row
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
.FreezePanes = True
End With
Next ws
End Sub