vba functions are not under application.(dot)

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I wanted to use Trim function (Application.Trim) in my code. So I went to Object Browser and typed Application, thinking that under Application, I will see these functions. Otherwise why it is (Application.trim). But to my surprised, I could not find Trim or other functions under Application!! So I typed Trim and found out Trim is member of Strings Class and String is under VBA

So it is VBA.Strings.Trim

So my question, why people say Application.Trim? and it does work application.trim?

Thank you very much
 

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
Trim is a WorksheetFunction, so it should be
Code:
Application.worksheetfunction.trim
although you can missout either the Application, or the worksheetfunction & it will work
 
Upvote 0
There is also a native VBA Trim function which doesn't behave quite the same way as the Worksheetfunction version. (It doesn't trim multiple spaces within a word)
 
Upvote 0
Thank you all. I wrote the following code and only line 2, did the job correctly
but I still not sure why I can not find Trim function under Application, using object browser
Thank you

Code:
Sub myvba_function()
    MsgBox VBA.Strings.Trim("     hello            there")
    MsgBox Application.Trim("     hello            there")
    MsgBox Trim("     hello            there")
End Sub
 
Last edited:
Upvote 0
The first and third are the same function.

The functions under Application are deprecated, which is why you can't see them. They are also late bound, hence no intellisense.
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,636
Members
452,662
Latest member
Aman1997

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