ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   mid function causes a compile error (https://www.excelbanter.com/excel-programming/374687-mid-function-causes-compile-error.html)

Brotherwarren

mid function causes a compile error
 
Hi all, I have a problem that I cannot solve.
I have a routine that prints various registers for groups of pupils.
the routine checks each of the controls on a userform
if the control is a checkbox and its value is true then the caption of
the checkbox is analysed.
This is where the problem occurs. I am using the following code,
whenever I run the sub, I get an error message along the lines of
"compile error: cannot find project or library"
Here's the code -

For Each thing In RotationRegisterForm.Controls
If Mid(thing.Caption, 1, 2) = "11" Then
ActiveSheet.Range("rotStart11Dates").Range("a4").S elect


the rest of my code follows

I'm not sure what to do about it.
Also whenever I am naming a range of cells in excel I get an identical
error message to the one above. Is the problem caused by one of the
names I have chosen for a range?


Andrew Taylor

mid function causes a compile error
 
This kind of error usually means that the VBA project
has a missing reference. From the VBA window select
Tools/References, and look for any items marked
"Missing". Clearing the checkboxes for these may
solve the problem: if you get new errors saying
"Unknown Type" or similar then you may need to
reinstall some DLLs.


Brotherwarren wrote:
Hi all, I have a problem that I cannot solve.
I have a routine that prints various registers for groups of pupils.
the routine checks each of the controls on a userform
if the control is a checkbox and its value is true then the caption of
the checkbox is analysed.
This is where the problem occurs. I am using the following code,
whenever I run the sub, I get an error message along the lines of
"compile error: cannot find project or library"
Here's the code -

For Each thing In RotationRegisterForm.Controls
If Mid(thing.Caption, 1, 2) = "11" Then
ActiveSheet.Range("rotStart11Dates").Range("a4").S elect


the rest of my code follows

I'm not sure what to do about it.
Also whenever I am naming a range of cells in excel I get an identical
error message to the one above. Is the problem caused by one of the
names I have chosen for a range?



Tom Ogilvy

mid function causes a compile error
 
See answer to later posting of this question.

--
Regards,
Tom Ogilvy


"Brotherwarren" wrote:

Hi all, I have a problem that I cannot solve.
I have a routine that prints various registers for groups of pupils.
the routine checks each of the controls on a userform
if the control is a checkbox and its value is true then the caption of
the checkbox is analysed.
This is where the problem occurs. I am using the following code,
whenever I run the sub, I get an error message along the lines of
"compile error: cannot find project or library"
Here's the code -

For Each thing In RotationRegisterForm.Controls
If Mid(thing.Caption, 1, 2) = "11" Then
ActiveSheet.Range("rotStart11Dates").Range("a4").S elect


the rest of my code follows

I'm not sure what to do about it.
Also whenever I am naming a range of cells in excel I get an identical
error message to the one above. Is the problem caused by one of the
names I have chosen for a range?



Brotherwarren

mid function causes a compile error
 
many thanks to all those who replied. Tom Ogilvy's approach of
qualifying MID with vba. prefix helped! Cheers again.



All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com