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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top