agsteel
04-19-2017, 11:06 AM
I am hoping to get some help write some code to help me clean up excel worksheet by deleting rows of certain criteria true for value in a specific column. I am able to get it to work when I predefine threshold in code itself but I would like to have an assumption that can be changed and it deletes based on the input or assumption cell.
Below is code I use to delete rows when value in column K is greater than 100. Rather than define 100 upfront I would like to look at value entered in another worksheet in cell C5, and only delete row if value in column K is greater than the value in "worksheet x" and cell C5.
Any help on this would be appreciated. I am not experienced in VBA and current code was found in another thread.
Sub test()
Range("A3").Select
Dim x As Long, lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 12).Value > 100 Then
Rows(x).Delete
End If
Next x
Below is code I use to delete rows when value in column K is greater than 100. Rather than define 100 upfront I would like to look at value entered in another worksheet in cell C5, and only delete row if value in column K is greater than the value in "worksheet x" and cell C5.
Any help on this would be appreciated. I am not experienced in VBA and current code was found in another thread.
Sub test()
Range("A3").Select
Dim x As Long, lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For x = lastrow To 1 Step -1
If Cells(x, 12).Value > 100 Then
Rows(x).Delete
End If
Next x