Thread: copy and paste
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Eric Eric is offline
external usenet poster
 
Posts: 1,670
Default copy and paste

I replaced form6 with 4059 and 4069 (they are the two mix types I have for
results at this time). Neather one worked. I got no errors. The macro went
through its passes but didn't copy the last four test results.

"JLGWhiz" wrote:

Try making Form6 = 4056 and see if it works.

"Eric" wrote:

when I use this macro it doesn't work. Nothing happens and I don't get any
error reports. I am at a loss. Here it is....

Sub last_four_four()


Dim lr4, lc4, mCnt, cnt As Long
With Worksheets("last four")
lr4 = .Cells(Rows.count, 2).End(xlUp).Row
lc4 = .UsedRange.Columns.count + 1
mCnt = Application.CountIf(.Range("A71:A" & lr4), form6)
If mCnt = 4 Then
mCnt = 4
End If
cnt = 1
For i = lr4 To 71 Step -1
If .Cells(i, 1) = form6 Then
If cnt <= 4 Then
Select Case mCnt
Case Is = 1
.Range(.Cells(i, 2), .Cells(i, lc4)).Copy .Range("B9")

Case Is = 2
If x = "" Then x = 10
.Range(.Cells(i, 2), .Cells(i, lc4)).Copy .Range("B&x")
x = x - 1

Case Is = 3
If x = "" Then x = 11
.Range(.Cells(i, 2), .Cells(i, lc4)).Copy .Range("B&x")
x = x - 1

Case Is = 4
If x = "" Then x = 12
.Range(.Cells(i, 2), .Cells(i, lc4)).Copy .Range("B&x")
x = x - 1

End Select
cnt = cnt + 1
End If
End If
Next
End With
End Sub

Where it says form6 I was told to use a variable. I was using a number of
101.

Any help would be appreciated. Thank you

Eric