+ Reply to Thread
Results 1 to 5 of 5

Autofilter in Vba works fine for code in button_click but dosen't work as a function

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    india,hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    1

    Autofilter in Vba works fine for code in button_click but dosen't work as a function

    Dear all ,

    Please find Excel Sheet "testrange.xlsm"

    I have a peculiar problem i have a code written to filter data in module1 which is asigned to button_click1 and works fine
    but the same code as "module2" called as function dosen't show the same results.

    Regards,
    Raji
    Attached Files Attached Files
    Last edited by rejilce; 01-04-2015 at 01:00 PM. Reason: forgot to attach excel file

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Autofilter in Vba works fine for code in button_click but dosen't work as a function

    I believe a function is more or less just a Custom Formula, I don't think it can do actions like your macro can.I really haven't used UDF's much though
    Last edited by davesexcel; 01-04-2015 at 01:27 PM.

  3. #3
    Registered User
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Autofilter in Vba works fine for code in button_click but dosen't work as a function

    I tested it, seems like it shows the same result for me? What comes up for you differently?

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Autofilter in Vba works fine for code in button_click but dosen't work as a function

    What comes up for you?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,453

    Re: Autofilter in Vba works fine for code in button_click but dosen't work as a function

    Using this:

    Please Login or Register  to view this content.

    I get the same output.


    However, a worksheet function can only make changes to the cell that it resides in. It cannot affect the rest of the worksheet, hence it cannot filter data, etc.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Advanced Filter Macro does not work, running manually works fine
    By jamiemc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-09-2013, 07:22 PM
  2. Getting this code to work on MAC (ERROR 68) - works fine on Windows
    By LT1511 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2012, 11:09 PM
  3. How 2 Execute Sheet1 Button_Click Code from a module function
    By sparker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2005, 07:05 PM

Tags for this Thread

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