Compile Error in VBA

LeonardH

New Member
Joined
Dec 21, 2013
Messages
33
Office Version
  1. 365
Platform
  1. Windows
I've been looking through a bunch of searches and other things an can't seem to find anything to help get rid of this error message. I started using VBA for the first time two days ago and have been having a blast, but this one baffles me.

VBA Compile error:
Variable not defined

My code is:

Option Explicit
Private Sub Worksheet_Activate()
programEntry.Show
End Sub

"Private Sub Worksheet_Activate()" is highlighted in yellow.
Error occurs after switching to a different sheet in the workbook and then back again.

Thanks for your help. Let me know if you have any other questions.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello

Do you have a userform called programEntry, in the same file?
 
Upvote 0
I don't think so. I was trying to follow a tutorial on YouTube and I wasn't sure where they got that. The forms that I made for the file are Accounts, DeductionSetup, ExpenseSetup, and IncomeSetup. Modules are codeAccount, codeDeduction, codeExpense,and codeIncome.

In the sheet the forms work fine the first time I go to the sheet, but when I switch back from a different sheet that error appears. It also works again when I press the Reset button in VBA.

Also, I have a few buttons on that sheet that are supposed to open the forms. I would prefer that the forms only open when the buttons are clicked on. I don't know if that helps at all.

Thanks so much!!
 
Last edited:
Upvote 0
So I figured it out. After the last post, I realized that code was given to the first sheet. There is not a form named programEntry and because I already had everything set up otherwise, all I had to do was delete the code entirely. It works now the way that I would like it to.

Thank you wigi. Had you not said anything, I'm sure I would still be at a loss!!

Thanks again,

LeonardH
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,267
Members
449,149
Latest member
mwdbActuary

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