View Single Post
 
Old 01-08-2022, 06:03 AM
Matt C's Avatar
Matt C Matt C is offline Windows 10 Office 97-2003
Advanced Beginner
 
Join Date: May 2021
Location: London, UK
Posts: 30
Matt C is on a distinguished road
Default

Hi. Thanks for this. It half works.

I've added the line as you suggested:

Quote:
Function SumCat(WorkRng As Range)
'
' SumCat Function
'
' Calculates cells formatted as "Total Category"
' Example: =SUMCAT(A1:C9)
'
Dim rng As Range
Dim xSum As Long

Application.Volatile

For Each rng In WorkRng
' Finds cells with "Total Category" stylename
If rng.Style = "Total Category" Then
xSum = xSum + rng.Value
End If

Next

SumCat = xSum

End Function
The "Insert Row" macro (see code in first post) now seems to work fine, but I'm still getting the error after running the "Delete Row" macro (code below).

Quote:
Sub DeleteRow()
'
' DeleteRow Macro
'
response = MsgBox("Are you sure you want to remove this row?", vbYesNo)

If response = vbYes Then

ActiveCell.Rows("1:1").EntireRow.Select
Selection.Delete Shift:=xlUp

Else
Exit Sub

End If

End Sub
As before, deleting a row manually does not result in the "#VALUE!" error.
Reply With Quote