Good Afternoon,
I am working on a macro that will take a large amount of data, pivot it by source code. What I am wanting to build is a formula that will use my below endColumn dim in the formula as the number of columns in this report could be variable as we clean up source codes.
The below is the dim and the formula I am trying to use it in. I use offset to get to the cell I need to, that works fine. I want to amend the formula to accept the endColumn dim so the formulas will be variable.
When I run this code I get a Application defined or object-defined error.
Any help would be much appreciated!
Dim endRow As Long
Dim rangeOne As Range, rangeTwo As Range
Dim endColumn As Long
endRow = Sheets("CombinedPivot").Cells(Rows.Count, 1).End(xlUp).Row
endColumn = Sheets("CombinedPivot").Range("A1").End(xlToRight).Column
Selection.End(xlToRight).Offset(0, 1).Value = "Max of Source Code 1"
Range("A1").Select
Selection.End(xlToRight).Offset(1, -3).Value = "=IFERROR(LARGE(B2,&endColumn&,1),""N/A"")"
Bookmarks