larinda4
Board Regular
- Joined
- Nov 15, 2021
- Messages
- 74
- Office Version
- 365
- Platform
- Windows
I have part of my code below and it requires a little tweaking.
Breakdown: I have two worksheets, one called PivotTable and another called PerC. In my PivotTable worksheet, there is a value in Q2 that generally changes every month. I want it to go through column J and find any values that are greater than Q2. If it is greater than Q2, I want it to copy the value in column A and paste it into the PerC worksheet in cell G2. I want it to continue looking through column J and essentially create a list in the PerC worksheet column G.
Currently my code doesn't account for pasting it in the next cell under G2 and then continuing to do so for as many times as it needs to. It'll just continue to override G2.
Any help is appreciated!
Breakdown: I have two worksheets, one called PivotTable and another called PerC. In my PivotTable worksheet, there is a value in Q2 that generally changes every month. I want it to go through column J and find any values that are greater than Q2. If it is greater than Q2, I want it to copy the value in column A and paste it into the PerC worksheet in cell G2. I want it to continue looking through column J and essentially create a list in the PerC worksheet column G.
Currently my code doesn't account for pasting it in the next cell under G2 and then continuing to do so for as many times as it needs to. It'll just continue to override G2.
Any help is appreciated!
VBA Code:
Sub TestIDLabels()
Dim r As Range, filesheet As Worksheet, Rng As Range
Set filesheet = Sheets("PivotTable")
Set Rng = filesheet.Range("J3", filesheet.Range("J" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants, xlNumbers)
For Each r In Rng
If r.Value > Range("Q2") Then 'This range is in the PivotTable worksheet
ActiveCell.Offset(0, -9).Select
ActiveCell.Copy
Worksheets("PerC").Select
Range("G2").Select
Selection.PasteSpecial Paste:=xlPasteValues
End If
Next r
End Sub