Unique formula to return data to last row

windb

New Member
Joined
Mar 12, 2016
Messages
23
Please can someone tell me how I can amend this formula so that it returns all numbers in column F up to the last row, i.e. so that I can use it repeatedly on workbooks which have different rows of data.

VBA Code:
    Sheets("Lists").Select
    Range("A2").Select
    ActiveCell.Formula2R1C1 = _
        "=SORT(UNIQUE(FILTER('Report'!RC[5]:R[468]C[5]))"
    Range("A3").Select
End Sub

Note - the last row has previously been declared as a variable within the existing macro I've built, as follows:

Dim LR As Long
LR = Cells(Rows.Count, 1).End(xlUp).Row

I've tried tagging "LR" onto the formula with no success.

Note- the "LR" variable is based on the no. of rows in a different sheet called "Report".

I am looking for the results to return to the "Lists" tab.

Many thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
In future when posting code, please use code code tags, rather than making everything bold How to Post Your VBA Code

How about
VBA Code:
    Sheets("Lists").Select
    Range("A2").Formula2R1C1 = _
        "=SORT(UNIQUE(FILTER('Report'!RC[5]:R" & LR & "C[5]))"
    Range("A3").Select
 
Upvote 0
Solution
In future when posting code, please use code code tags, rather than making everything bold How to Post Your VBA Code

How about
VBA Code:
    Sheets("Lists").Select
    Range("A2").Formula2R1C1 = _
        "=SORT(UNIQUE(FILTER('Report'!RC[5]:R" & LR & "C[5]))"
    Range("A3").Select
Many thanks Fluff. That works. I've removed the Filter part of the equation as it's not needed, and in any case, the formula doesn't work with it. Useful to know about code tags too. Great stuff.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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