Thread: InsertFirst
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
kyoshirou kyoshirou is offline
external usenet poster
 
Posts: 133
Default InsertFirst

u'r right. Everything need to search from top to bottom.
I can have it search from top to bottom also.
But is it possible to have the new values on top?
That what i trying to create.

"steve_doc" wrote:

Theoretically you wouldn't need to find the last row if you plan to insert on
the first row

The following will insert a new row after your column headings(assuming you
have Column headings)

With ws.Range("A1:J1")
.Offset(1, 0).Rows.Insert
End With

HTH

"kyoshirou" wrote:

Firstly, if new record has been inserterd, i feel that is better to save on
the 1st row for easy reference.

Steve, so is it possible to finds the last used row, then inserts the new
data to the first row?

"steve_doc" wrote:

Not sure why you would want to save to the 1st row.

The procedure that you listed, finds the last used row, then inserts the new
data to the row offset by 1 row.
If you have no data, the procedure will use the 1st row.

If its that you want to insert Column headings for your data, you could use

With historyWks.Range("A1:F1")
.Value = VBA.Array("Title1", "Title2", "Title3", "Title4", "Title5",
"Title6")
.Font.Bold = True
End With

HTH

"kyoshirou" wrote:

Hello..

I have this code:
As new data is save at the last row, how do i make it to save on the first
row? Do i use FirstRow?

Any website to teach?

Thanks!


Set inputWks = Worksheets("MAIN")
Set historyWks = Worksheets("Data")

With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With