Find and paste data into first blank row in table

lwebbie

New Member
Joined
Feb 28, 2017
Messages
24
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
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

NoSparks

Well-known Member
Joined
Mar 15, 2013
Messages
888
Office Version
2010
Platform
Windows

lwebbie

New Member
Joined
Feb 28, 2017
Messages
24
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
 

Watch MrExcel Video

Forum statistics

Threads
1,099,462
Messages
5,468,786
Members
406,608
Latest member
G3TEN

This Week's Hot Topics

Top