Cannot use "Right" Function. Apparently meaning has changed.

Engineer123

New Member
Joined
Nov 21, 2019
Messages
6
I have a large VBA project I'm working on that uses the "Right" function a lot. All of a sudden it gives me an error message of...

"Compile Error

Wrong number of arguments or invalid property assignments."

When I try to compile, with the "Right" Function highlighted. What's really strange is that it worked earlier and it worked in other files.
The following code...

Private Sub RightTester()
'This should trigger a message box with the letter "g'
MsgBox (Right("String", 1))
End Sub

… works perfectly in a blank file. And will work for a while if I copy all the code into a blank file and start from there. I thought that somehow a function library got changed in that file. But it doesn't work consistently in any file I work with for any amount of time. What's really strange is that "Left" works perfectly.

Does anyone have any idea what's going on?
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,849
Office Version
365
Platform
Windows
Check that you don't have any procedures, or variables called Right
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,849
Office Version
365
Platform
Windows
Glad to help & thanks for the feedback.

It's always best to avoid using VBA keywords for Procedures/variables, for just this reason. ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,099,378
Messages
5,468,265
Members
406,576
Latest member
mbehring

This Week's Hot Topics

Top