Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding stuff to last row after some rows have been removed?

Status
Not open for further replies.

Usva

Programmer
Jun 8, 2004
4
0
0
FI
I have a problem with Excel. Ive made a button that copies pre-made information from row and adds it on first empty row at end of a table on another sheet. Problem is that when a row is removed or cleared the first empty row is actually row after the row where data was last time copied.

Like:
-table is empty
-add 2 new rows of data witht he button
-now last empty row is row number 3
-remove those added rows
-add data at first empty row using the button
-data is added on 3rd row leaving 2 empty rows above

Here is the code:

Private Sub CommandButton3_Click()
Sheets("valmiit").Select
ActiveSheet.Range("A1:J1").Copy
Sheets("työlista").Select
Dim LastRow As Long
LastRow = ActiveCell.SpecialCells(xlLastCell).Row + 1
Worksheets("työlista").Cells(LastRow, 1).EntireRow.Select
ActiveCell.Offset(0, -ActiveCell.Column + 1).Select
ActiveSheet.Paste
End Sub

Does anyone have some solution to this? Ive tried with removing entire row and clearing it from everything, but neither of those works.
 
Hi Usva
Check out the FAQ section as there are two FAQs on the subject of finding the TRUE last Row/Cell.

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Thanks that helped :)

Now I have some new problems, but ill try first by myself. Last time i used excel was about 5 years ago and ive never programmed with VB, so this aint really too easy :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top