Find and paste data into first blank row in table

lwebbie

New Member
I am working on a macro that needs to be able to pastedata into a table. The macro does several different filters and after eachfilter the results should be copied and pasted to a table. The issue I amhaving is the table it is copying to starts on B17 (there are blank rows andother tables above it).
I have had no issue accomplishing the same thing on othermacros but the table always starts in A1.

Below is the start of the macro code (I know it can becleaner, I just use the macro recorder and clean it up as best I can). Thefirst filter, copy, and paste is fine but then once the second filter is done Idon’t know how to tell it to paste in the first blank row after the data itjust pasted since that cell will always be different.

Windows("Pivot Data Template.xlsx").Activate
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("A1").AutoFilter Field:=1, Criteria1:= _
"JohnSmith"
ActiveSheet.Range("A1").AutoFilter Field:=6,Criteria1:="10", _
Operator:=xlTop10Items
Range("A2", Cells(Rows.Count,"A").End(xlUp)).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("XH Reports Template-OR.xlsm").Activate
Range("Table17[Manager]").Select
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,SkipBlanks _
:=False,Transpose:=False
Windows("Pivot Data Template.xlsx").Activate
ActiveSheet.Range("A1").AutoFilter Field:=1, Criteria1:= _
"JaneDoe"
Range("A2", Cells(Rows.Count,"A").End(xlUp)).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select
Range(Selection,ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("XH Reports Template-OR.xlsm").Activate
Range("Table17[Manager]"& Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues,Operation:=xlNone, SkipBlanks _
:=False,Transpose:=False
 

lwebbie

New Member
Thanks, I have used the spreedsheetguru page a lot for working with tables.

I was able to get the code to work by doing Range("Table17").End(xlDown).Offset(1).PasteSpecial xlPasteValues
 

Some videos you may like

This Week's Hot Topics

Top