Trueblue862
Board Regular
- Joined
- May 24, 2020
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
Hi, I have this piece of code which I'm using to delete products from a database, but when I run it I get a #REF error on other sheets which have a formula dependent on the items I have deleted. I have tried replacing "Delete" with "ClearContents" and then running my sort macro. This doesn't give me the problem with the formulas, but the sort macro gets stuck on the empty row and doesn't move past it. What would be the best way to solve this problem.
This is my delete macro.
This is my sort macro.
This is my delete macro.
VBA Code:
Private Sub DeleteRow()
Dim iRw As Integer
Dim wsWS As Worksheet
Set wsWS = Worksheets("Order Sheet")
iRw = cbxItem.ListIndex + 2 'listindex starts at 0, plus a header row, so +2
wsWS.Cells(iRw, 1).EntireRow.Delete
End Sub
This is my sort macro.
VBA Code:
Sub Sort_Me()
With Worksheets("Order Sheet").Range("$A$2").CurrentRegion
.Sort Key1:=.Columns(1), Header:=xlYes, Order1:=xlAscending
End With
End Sub