vba string problems

excel_lint

New Member
Joined
Apr 2, 2002
Messages
4
When I run this subroutine:

Sub test_macro()
String1 = "Hello World"
String2 = Right(String1, 3)

End

I get this compile error message:
"Can't find project or library"
It shows the line:
String2 = Right(String1, 3)
with "Right" in bold.

I know this is something very simple but I'm unable to figure it out.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
On 2002-04-03 12:49, excel_lint wrote:
When I run this subroutine:

Sub test_macro()
String1 = "Hello World"
String2 = Right(String1, 3)

End

I get this compile error message:
"Can't find project or library"
It shows the line:
String2 = Right(String1, 3)
with "Right" in bold.

I know this is something very simple but I'm unable to figure it out.

I've copied your macro to my worksheet and it works fine. Try to do the same in another workbook.
End with 'End Sub'
Eli
This message was edited by eliW on 2002-04-03 14:36
 
Upvote 0
Hi excel_lint

While in the VBE go to Tools>Refrences the missing reference will be preceded with the word "Missing" use the browse button to locate and load it.
 
Upvote 0
Thanks, I opened a new worksheet and it worked fine. Don't know why it won't work in the orginal but this solution will get me going.
--------------
On 2002-04-03 14:35, eliW wrote:
On 2002-04-03 12:49, excel_lint wrote:
When I run this subroutine:

Sub test_macro()
String1 = "Hello World"
String2 = Right(String1, 3)

End

I get this compile error message:
"Can't find project or library"
It shows the line:
String2 = Right(String1, 3)
with "Right" in bold.

I know this is something very simple but I'm unable to figure it out.

I've copied your macro to my worksheet and it works fine. Try to do the same in another workbook.
End with 'End Sub'
Eli
This message was edited by eliW on 2002-04-03 14:36
[/quote]
 
Upvote 0
If you do not see a missing reference, change your code as follows:

String2 = Right(String1, 3)
String2 = Strings.Right(String1, 3)

That should solve your problem

Tom
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

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