UnsolvedCoding
Technical User
Hey all-
This one is stumping me.
I have a page where a summary of information is listed. When a cell in column N is highlighted by the user, the sub is to delete the row of information indicated by the highlighted cell.
Here's the problem - deleting the row of information with the highlighted cell will work to delete information if its not all together, if I run a handful of highlighted cells in consecutive rows it won't delete all the rows and I can't figure out why.
Any ideas?
Here's the entire code
Private Sub Clear_Highlighted()
' Just in case
On Error GoTo Error_Handler
Application.StatusBar = "Clearing highlighted rows"
i = 2
Do Until Trim(ThisWorkbook.Worksheets("2-Info").Cells(i, "G").Value) = "Grand Total:"
' Check if there is fill in the cell
If ThisWorkbook.Worksheets("2-Info").Cells(i, "N").Interior.ColorIndex <> xlNone Then
'Remove unwanted info
ThisWorkbook.Sheets("2-Info").Range("E" & i & ":N" & i).Delete Shift:=xlUp
End If
'Move down one row
i = i + 1
Loop
' Tell the user its done
Application.StatusBar = False
Exit Sub
Error_Handler:
Warning_Flag = 1
MsgBox Err.Description
Application.StatusBar = "Clear_Highlighted Failed. " & Err.Description
End Sub
This one is stumping me.
I have a page where a summary of information is listed. When a cell in column N is highlighted by the user, the sub is to delete the row of information indicated by the highlighted cell.
Here's the problem - deleting the row of information with the highlighted cell will work to delete information if its not all together, if I run a handful of highlighted cells in consecutive rows it won't delete all the rows and I can't figure out why.
Any ideas?
Here's the entire code
Private Sub Clear_Highlighted()
' Just in case
On Error GoTo Error_Handler
Application.StatusBar = "Clearing highlighted rows"
i = 2
Do Until Trim(ThisWorkbook.Worksheets("2-Info").Cells(i, "G").Value) = "Grand Total:"
' Check if there is fill in the cell
If ThisWorkbook.Worksheets("2-Info").Cells(i, "N").Interior.ColorIndex <> xlNone Then
'Remove unwanted info
ThisWorkbook.Sheets("2-Info").Range("E" & i & ":N" & i).Delete Shift:=xlUp
End If
'Move down one row
i = i + 1
Loop
' Tell the user its done
Application.StatusBar = False
Exit Sub
Error_Handler:
Warning_Flag = 1
MsgBox Err.Description
Application.StatusBar = "Clear_Highlighted Failed. " & Err.Description
End Sub