Macro Not Running: Compile Error

poorwallace

Active Member
Joined
Mar 8, 2005
Messages
365
Hello All,

This is probably a pretty easy question, but I'm having problems stepping into or running a macro from the VBE. When I hit F8 to step through it or the run button, I just get a "Compile Error: Expected Expression".

I must note, though, that the macro runs fine if I run it by hitting ALT+F8 in normal Excel mode and then hit the run button.

I'm curious to find out why this is happening...

Any assistance would be greatly appreciated!
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

poorwallace

Active Member
Joined
Mar 8, 2005
Messages
365
Sure, below is the code. I'm running Excel 2003. And, yes, there are values in both column N (14) and C (3)

I'm curious to see what's going on here...

Code:
Sub Name()

Dim RNG1 As Long
RNG1 = Cells(Rows.Count, 14).End(xlUp).Row
Dim Fname As Integer


For Each Cell In Range(Cells(1, 14), Cells(RNG1, 14))
    
    If Cell = "Yes" Then
    
    
    Fname = Cell.Offset(0, -11).Value
    ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
    ActiveSheet.Name = Fname
    
    End If

Next

End Sub
 

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237

ADVERTISEMENT

You can't use Name as the name of a Sub.
 

poorwallace

Active Member
Joined
Mar 8, 2005
Messages
365
That was it! though I find it strange that I could still run the macro with ALT + F8 and hitting the "Run" button...

Thanks!
 

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
I thought that was weird myself, but as soon as I changed the name of the sub, everything was fine.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,057
Messages
5,569,954
Members
412,299
Latest member
agentless
Top