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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
That was it! though I find it strange that I could still run the macro with ALT + F8 and hitting the "Run" button...

Thanks!
 
Upvote 0
I thought that was weird myself, but as soon as I changed the name of the sub, everything was fine.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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
Back
Top