I'm looking to assign a variable to the final column in a sheet (column changes based on data) and use this variable in a formula to reference the column.
This returns a type mismatch . Ideally i want my x variable to represent some column range (e.g P:P).
Can anyone help me out?
VBA Code:
Dim x As Range
'this should assign x as the range variable for the final column
Cells(3, Columns.Count).End(xlToLeft).Select
ActiveCell.EntireColumn.Select
Set x = Selection
'inserting the following formula into some other cell
ActiveCell.FormulaR1C1 = "=LARGE(" & x & ",2)"
This returns a type mismatch . Ideally i want my x variable to represent some column range (e.g P:P).
Can anyone help me out?