COMPILE ERROR WHEN OPENING WORKBOOK BUT CODE RUNS FINE AFTER CLOSING MESSAGE

chazrab

Well-known Member
Joined
Oct 21, 2006
Messages
918
Office Version
  1. 365
Platform
  1. Windows
The best way I can explain this is with images below. Listbox1 is on the left, large Textbox3 on the right.
Excel's compile keeps trying to identify Textbox3 as a variable saying its not defined, which of course its not.
Textbox3 is the large textbox. Everything in the code below works great after its in run mode. Its only when
the workbook is closed and reopened does this problem appear. I can't figure it out. This is all on a SHEET, NOT
a userform, But that should make no difference - should it ? Code:

VBA Code:
Private Sub Worksheet_Activate()
ListBox1.Visible = True
ListBox1.Height = 337.5
 Me.ListBox1.ListIndex = 0
End Sub

Why is excel trying to recognize Textbox3 highlighted in blue and Listbox1 in yellow as a variable and issuing a Compile error message?
We know its a Textbox object - not a variable.

Something simple I can't figure out.
Please help with this if you see what's happening here .

Thanks for anyone's help.
cr
 

Attachments

  • VARIABLE NOT DEFINED AT THIS POINT.jpg
    VARIABLE NOT DEFINED AT THIS POINT.jpg
    86.5 KB · Views: 23
  • CODE RUNS FINE AFTER EXITING DEBUG IN RUN MODE.jpg
    CODE RUNS FINE AFTER EXITING DEBUG IN RUN MODE.jpg
    44.2 KB · Views: 25

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Does your workbook in fact contain a sheet whose code name is Sheet28 and that contains an ActiveX textbox named TextBox3?
 
Last edited:
Upvote 0
Yes. The images below show that Sheet2 on the tree view and below in the tab section.
The sheet name these objects are on is BIBLETEXT as shown below. From your question, you can see something that's
causing this I don't see. I should be able to open and close this workbook, make changes, save changes, close the workbook
and reopen it without that Compile error being generated - unless I'm missing something that Excel is reading I can't see or find.

Thanks for all your help.
 

Attachments

  • SHEET2 REFERENCES.  .jpg
    SHEET2 REFERENCES. .jpg
    61.2 KB · Views: 24
  • LISTBOX1 OBJECT AND ACTIVE SHEET NAME. SHEET2 IS RIGHT NEXT TO IT.jpg
    LISTBOX1 OBJECT AND ACTIVE SHEET NAME. SHEET2 IS RIGHT NEXT TO IT.jpg
    58.7 KB · Views: 20
  • LISTBOX1 TEXTBOX3 AND BIBLETEXT SHEET WITH SHEET2 NEXT TO IT..jpg
    LISTBOX1 TEXTBOX3 AND BIBLETEXT SHEET WITH SHEET2 NEXT TO IT..jpg
    159.4 KB · Views: 25
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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