Pasting info from another sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

I have a sheet with four test results on it to review. As I run a new test
(on a different sheet) I want the earliest test to fall off the sheet and
paste the latest one. Is this possible?

Eric
 
Is the earliest test alway in the same spot (like the top or bottom?) what
are you doing to run the test ie button click etc to let the program know
that a new test is ready?
 
I would click a button "post test". The test information is in columns
(three tests to a sheet but all three may not be used). Once I click "post
test" the information is transphered to a data sheet where all tests are kept
with the latest one on the bottom row. I may have 400 rows of test
information but I only want to show the last four on the "last four" sheet.

Does this help?

Eric
 
this isn't the most perfect way to do this, but probably the easiest for you
to understand what i'm doing. Change sheet1 to the sheet that has all of the
test data (like 400 rows) sheet 2 is the sheet with just the four latest.
change the line For i = 4 to 1 step -1 to be what cells you want populated,
if you have titles for example you probably want 5 to 2.

Sub main()
Dim lastRow As Long
Dim myRow As Long
Dim myCol As Long

lastRow = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
myRow = 1
myCol = 1
For i = 4 To 1 Step -1
Do Until Sheets("sheet1").Cells(lastRow, myCol) = ""
Sheets("sheet2").Cells(i, myCol) = Sheets("sheet1").Cells(lastRow, myCol)
myCol = myCol + 1

Loop
lastRow = lastRow - 1
myCol = 1

Next
End Sub
 

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

Back
Top