Mishka4595
New Member
- Joined
- Nov 17, 2020
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
i'm new to both macros and vba
I have a pivot table in sheet FR Pivot and a table in sheet Final. I want to pick up the pivot table data and use vlookup to fill in values in my table in the Final sheet. The issue is that the pivot table can be dynamic. So I'm trying the following:
I think I'm going wrong with the named range part but unable to figure out how to fix it. For the macro, I'm recording my actions and then modifying code to make it dynamic which is why there are so many selects.
I have a pivot table in sheet FR Pivot and a table in sheet Final. I want to pick up the pivot table data and use vlookup to fill in values in my table in the Final sheet. The issue is that the pivot table can be dynamic. So I'm trying the following:
VBA Code:
Dim Range1 As Range
With Sheets("FR Pivot")
.Range("E4").Select
Selection.CurrentRegion.Select
Set Range1 = Selection
End With
Sheets("Final").Select
Range("J7").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(VLOOKUP([@[Row Labels]],Range1,2,0),""NA"")"
I think I'm going wrong with the named range part but unable to figure out how to fix it. For the macro, I'm recording my actions and then modifying code to make it dynamic which is why there are so many selects.