VBA Compile error Label not defined

bkey01

New Member
Joined
Apr 12, 2004
Messages
25
I have an Excel workbook with multiple listbox's and command button. I have set an errhandler for printing. The first time it worked find and know I am getting an error that says:
Compile error
Label not found
for errhandler7

Ex. code

if listbox1.selected(7) then goto errhandler7
listbox1.selected(7)=false

errhandler7:
sheet1.printout
sheet2.printout
sheet3.range("a1:aa40").print

Can anyone help
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I would say your problem is that you're using End Sub at all of those. You've effectively made it so that anything after the End Sub at the end of errhandler1 isn't included in the macro.

Put End Sub at the end of your code and EXIT sub in place of the rest and give it a go.

This post (from 2004) finally resolved the same issue. Been stuck for 2 days on this problem - Thanks Kristy & Greg
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,970
Members
449,276
Latest member
surendra75

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