-
Apr 8th, 2021, 12:19 AM
#1
Thread Starter
New Member
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.
Thanks
-
Apr 8th, 2021, 01:17 AM
#2
Re: Function not running from excel
Is it a Public Function in a Standard Code-Module?
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE 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.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Apr 8th, 2021, 03:58 AM
#3
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
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
Target.Resize(8).Select
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
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|