473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

Hi,

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()
  2.  
  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
  11.  
  12. End Sub

Thanks, D
Feb 3 '11 #1
1 15001
Stewart Ross
2,545 Expert Mod 2GB
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.

-Stewart
Feb 3 '11 #2

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

Similar topics

8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
1
by: Steve | last post by:
I get this message when I tried to make a .MDE of my database. "Compile error in hidden module: Form_frmPurchaseReq" I have been using this database for several months and just thought I would...
10
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
2
by: yinglcs | last post by:
I have the following code, which use template as the parent class of my other class. But I have "instantiated from here" compile error at this line: class C: public B2<A>. Can some one...
7
by: bikesandcars | last post by:
Hello guys, I stumbled upon this forum recently and am hoping someone here can help me with this problem. This is probably very stupid, but I can't get past this easy problem / glitch. All...
3
by: wwwursa | last post by:
I am trying to use the Right function in a VB6 program. I have used it used many times before in other programs. When I press the enter key after entering the code line, the word "Right" turns...
6
by: JHNielson | last post by:
This is a very simple question.... I have a form that looks up Records for an unbound drop-down list. It has worked just fine up until last night. Now the button on the form to delete a record...
4
by: James Lucero | last post by:
Below is my code. The error is "Compile Error Variable not defined". wdOrientLandscape is highlighted. Again this the portion of the code from a VB module created in Excel. The previous lines of code...
2
by: engrlorie | last post by:
I am a newbie in programing and is currently designing a program using VB6 with access 03 database. Unfortunately, I am stuck with the error. Please help me.. can't decipher the problem myself....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.