I have a problem. I have button that copies a row from one sheet and pastes it on another sheets first empty row. It works just fine, untill autofilter is used on page. When some of the parts are filtered the table gets shorter and when that button described above is used it leaves empty space equal to rows not visible due to filtering. Meaning if i have 100 rows and filter them by some part of the table and it leaves 30 rows visible and then use the button to add new pre-made row it wont add on first empty row but 70 rows below instead.
Well I tried turning off the autofilter for duration of paste and then adding the autofilter again, not selecting the used filter mode tho (would be too complicated for me
) But when i use it, it removes the autofilter but wont paste and gives runtime error 1004.
Here is the code:
Private Sub CommandButton3_Click()
Sheets("valmiit").Select
ActiveSheet.Range("A1:J1").Copy
Sheets("työlista").Select
ActiveSheet.Range("A3:J3").AutoFilter
Dim LastRow As Long
r = ActiveSheet.UsedRange.Rows.Count
c = ActiveSheet.UsedRange.Columns.Count
LastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row + 1
Worksheets("työlista").Cells(LastRow, 1).EntireRow.Select
ActiveCell.Offset(0, -ActiveCell.Column + 1).Select
ActiveSheet.Paste
ActiveSheet.Range("A3:J3").AutoFilter
End Sub
Does anyone have solution?
Well I tried turning off the autofilter for duration of paste and then adding the autofilter again, not selecting the used filter mode tho (would be too complicated for me
Here is the code:
Private Sub CommandButton3_Click()
Sheets("valmiit").Select
ActiveSheet.Range("A1:J1").Copy
Sheets("työlista").Select
ActiveSheet.Range("A3:J3").AutoFilter
Dim LastRow As Long
r = ActiveSheet.UsedRange.Rows.Count
c = ActiveSheet.UsedRange.Columns.Count
LastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row + 1
Worksheets("työlista").Cells(LastRow, 1).EntireRow.Select
ActiveCell.Offset(0, -ActiveCell.Column + 1).Select
ActiveSheet.Paste
ActiveSheet.Range("A3:J3").AutoFilter
End Sub
Does anyone have solution?