Hi all,
Nearly finished the current project and have one final hurdle.
I have just spent time going through the prior threads and cannot find what I'm after.
I have the code below and am fairly certain this is the long winded and inefficient way to attack the problem.
What I need to do is check the value of Column AT and return one of three values Master, Competent or Foundation. It then needs to delete any rows containing Master in Col AT where Col AV is greater than the value of the Variable Master (which is fed from a cell value in the Controls sheet. It then needs to do the same for Competent and Foundation in AT.
Any suggestions welcome (or more probably a point at a thread I missed!)
<CODE>
Sheets("Sample").Select
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim Master As Long
Dim Competent As Long
Dim Foundation As Long
Master = Worksheets("Controls").Cells(40, "H").Value
Competent = Worksheets("Controls").Cells(40, "I").Value
Foundation = Worksheets("Controls").Cells(40, "J").Value
Dim i As Long
i = 1
Do While i <= ThisWorkbook.ActiveSheet.Range("AV1").CurrentRegion.Rows.Count
If InStr(1, ThisWorkbook.ActiveSheet.Cells(i, 1).Value) > Master And ThisWorkbook.ActiveSheet.Range("AT1") = Master Then
ThisWorkbook.ActiveSheet.Cells(i, 1).EntireRow.Delete
Else
i = i + 1
End If
Loop
Dim j As Long
j = 1
Do While j <= ThisWorkbook.ActiveSheet.Range("AV1").CurrentRegion.Rows.Count
If InStr(1, ThisWorkbook.ActiveSheet.Cells(j, 1).Value) > Competent And ThisWorkbook.ActiveSheet.Range("AT1") = Competent Then
ThisWorkbook.ActiveSheet.Cells(j, 1).EntireRow.Delete
Else
j = j + 1
End If
Loop
Dim k As Long
k = 1
Do While k <= ThisWorkbook.ActiveSheet.Range("AV1").CurrentRegion.Rows.Count
If InStr(1, ThisWorkbook.ActiveSheet.Cells(k, 1).Value) > Foundation And ThisWorkbook.ActiveSheet.Range("AT1") = Foundation Then
ThisWorkbook.ActiveSheet.Cells(k, 1).EntireRow.Delete
Else
k = k + 1
End If
Loop
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
</CODE>
Regards
DaveA
Nearly finished the current project and have one final hurdle.
I have just spent time going through the prior threads and cannot find what I'm after.
I have the code below and am fairly certain this is the long winded and inefficient way to attack the problem.
What I need to do is check the value of Column AT and return one of three values Master, Competent or Foundation. It then needs to delete any rows containing Master in Col AT where Col AV is greater than the value of the Variable Master (which is fed from a cell value in the Controls sheet. It then needs to do the same for Competent and Foundation in AT.
Any suggestions welcome (or more probably a point at a thread I missed!)
<CODE>
Sheets("Sample").Select
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim Master As Long
Dim Competent As Long
Dim Foundation As Long
Master = Worksheets("Controls").Cells(40, "H").Value
Competent = Worksheets("Controls").Cells(40, "I").Value
Foundation = Worksheets("Controls").Cells(40, "J").Value
Dim i As Long
i = 1
Do While i <= ThisWorkbook.ActiveSheet.Range("AV1").CurrentRegion.Rows.Count
If InStr(1, ThisWorkbook.ActiveSheet.Cells(i, 1).Value) > Master And ThisWorkbook.ActiveSheet.Range("AT1") = Master Then
ThisWorkbook.ActiveSheet.Cells(i, 1).EntireRow.Delete
Else
i = i + 1
End If
Loop
Dim j As Long
j = 1
Do While j <= ThisWorkbook.ActiveSheet.Range("AV1").CurrentRegion.Rows.Count
If InStr(1, ThisWorkbook.ActiveSheet.Cells(j, 1).Value) > Competent And ThisWorkbook.ActiveSheet.Range("AT1") = Competent Then
ThisWorkbook.ActiveSheet.Cells(j, 1).EntireRow.Delete
Else
j = j + 1
End If
Loop
Dim k As Long
k = 1
Do While k <= ThisWorkbook.ActiveSheet.Range("AV1").CurrentRegion.Rows.Count
If InStr(1, ThisWorkbook.ActiveSheet.Cells(k, 1).Value) > Foundation And ThisWorkbook.ActiveSheet.Range("AT1") = Foundation Then
ThisWorkbook.ActiveSheet.Cells(k, 1).EntireRow.Delete
Else
k = k + 1
End If
Loop
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
</CODE>
Regards
DaveA
Last edited: