+ Reply to Thread
Results 1 to 3 of 3

VBA Code sort positive number only

  1. #1
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    VBA Code sort positive number only

    Please Login or Register  to view this content.
    I use above code to enter formula in cell E2, after running VBA code, the cell E2 is =@SORT(FILTER($N$2:$N$1048576,$N$2:$N$1048576>0),1,1) , no idea where @ comes from. I will need to manually remove @ , then the sorted data will be displayed.

    How to fix VBA code?

    Thanks.
    Attached Images Attached Images

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: VBA Code sort positive number only

    The "@" symbol is inserted into the formula because Excel is interpreting the formula as an array formula.
    When you use SORT and FILTER functions together, Excel treats it as an array formula by default, which is indicated by the "@" symbol.
    However, in this case, you don't want it to be treated as an array formula.

    To fix this issue, you can use the .Formula2 property instead of .Formula property.
    This property allows you to set the formula without the array formula syntax. Here's the modified code:

    Please Login or Register  to view this content.
    Using .Formula2 instead of .Formula should prevent Excel from inserting the "@" symbol into the formula, and your sorted data should be displayed correctly.
    Quang PT

  3. #3
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    Re: VBA Code sort positive number only

    Thank you so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to sort positive numbers only?
    By VAer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2024, 05:48 PM
  2. UK sort code and account number problem
    By sunshine1325 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-02-2020, 09:38 AM
  3. VB code to filter and move positive number to another column
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-09-2018, 12:25 PM
  4. [SOLVED] How to sum a positive and negative number so the total is positive
    By jminty95 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-15-2017, 09:27 PM
  5. Sort negative and positive numbers into their own columns?
    By More Cowbell in forum Excel General
    Replies: 6
    Last Post: 01-31-2015, 02:57 PM
  6. sort one positive and one negative number
    By vharjani in forum Excel General
    Replies: 8
    Last Post: 02-14-2012, 11:34 AM
  7. Amend code to Sort Sheets by number
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-02-2008, 09:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1