By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

How to fix "Compile error: Expected End Sub" in VBA Macro?

P: 1

I need help with VBA Macro for Auto-filter to high lite a header plp advice as per below course a I got Compile error: Expected End Sub ?

Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  3. Function FilterOn(myCell As Range) As Boolean
  4.     On Error Resume Next
  5.     With myCell.Parent.AutoFilter
  6.         With .Filters(myCell.Column - .Range.Column + 1)
  7.             If .On Then FilterOn = True
  8.         End With
  9.     End With
  10. End Function
  12. End Sub

Thanks, D
Feb 3 '11 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 2,545
You can't define a function (lines 3-10) WITHIN the definition of a SUB (lines 1 and 12). You can CALL the function from the sub, but they must be separately defined.

Feb 3 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.