Last 4 tests

E

Eric

I am using the following macro to list the last 4 tests but there is a slight
problem. this macro lists the last 4 tests regardless of what the mix type
is and I need it to list the last 4 tests according to the mix type I call
for.


Sub Last_four()

Dim rangeArray As Variant, r As Range
rangeArray = Array("Type_Mix")
For i = LBound(rangeArray) To UBound(rangeArray)
If IsEmpty(Range(rangeArray(i))) Then
MsgBox rangeArray(i) & " can not be blank"
Exit Sub
End If
Next i

Sheets("Last Four").Select

Dim lastrow As Long
Dim myrow As Long
Dim mycol As Long

lastrow = Sheets("test database").Cells(Rows.count, "A").End(xlUp).Row
myrow = 1
mycol = 1
For i = 12 To 9 Step -1
Do Until Sheets("test database").Cells(lastrow, mycol) = ""
Sheets("last four").Cells(i, mycol) = Sheets("test database").Cells(lastrow,
mycol)
mycol = mycol + 1

Loop
lastrow = lastrow - 1
mycol = 1

Next

'************** Adding up Volumetrics of Test********************

Dim cell As Range
Dim rng As Range
Dim counter As Long
counter = 0

Set rng = Worksheets("last four").Range("AG47:AG44")
For Each cell In rng
If cell.Value = True Then
counter = counter + 1
Else

Exit For
End If
Next

Range("AG49") = counter

end sub

My info is storred like this:

A B C D
23
23~~> list this row
23~~> list this row
29
28
23~~> list this row
23~~> List this row

I need to list the last 4 tests of #23. The macro above would list 29, 28,
23, 23, Can anyone help me out? Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top