Insert value based on amount pasted

The Power Loon

New Member
Joined
Feb 7, 2020
Messages
34
Office Version
  1. 365
Platform
  1. Windows
I have a VBA codes that pulls dozens of different categories of data, based on filters, from various columns in a source table in one sheet and then pastes them all into column C in another sheet. My issue is that once pasted into column C, it's impossible to distinguish which category the data belongs to. There are no corresponding designations in the source data I can paste with it, and the amount of data pasted varies.

What I'm trying to do is add a line in the VBA code, immediately after each pasting action, that will add a designation into column A aligning with the just pasted values. I've tried some offsets, but just can't get it figured out. Below is a sample of code for one of the filters. Is this possible?

ActiveSheet.ListObjects("Table4").Range.AutoFilter Field:=12, Criteria1:= _
">=.001", Operator:=xlAnd
Range("Table4[1st to 2nd]").Select
Range("B5").Activate
Selection.Copy
Sheets("Records").Select
Range("C1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Add "Filter Set 1" to Column A in the corresponding row of each newly pasted value.
Sheets("All Combinations").Select
ActiveSheet.ListObjects("Table4").Range.AutoFilter Field:=12
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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