Results 1 to 3 of 3

Thread: Function not running from excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021

    Function not running from excel

    Hi, I am executing the below mentioned function like a formula in excel worksheet. But it is not giving the desired output ie. selecting 8 rows below the activecell.
    However, it is working fine if I run the function from the VBA editor.
    Can somebody please help?

    Function sel()
    Range(ActiveCell, ActiveCell.Offset(8, 0)).Select
    End Function

    I tried it with subroutine too. Again, it is running fine from VBA editor but the run option is greyed out in macros tab. Please help.


  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    To the moon and then left

    Re: Function not running from excel

    Is it a Public Function in a Standard Code-Module?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    For health reasons i try to avoid reading unformatted Code

  3. #3
    Join Date
    Dec 2004

    Re: Function not running from excel

    worksheet functions do not work like that

    you would probably be better to work with the worksheet change event, like
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Application.EnableEvents = False
        Application.EnableEvents = True
    End Sub
    you can limit this so it will only work with specific ranges
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed

Posting Permissions

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

Click Here to Expand Forum to Full Width