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!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

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
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.
 

Forum statistics

Threads
1,172,162
Messages
5,879,378
Members
433,425
Latest member
calinorth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top