Retrieve information within a variable

finaljustice

Board Regular
Joined
Oct 6, 2010
Messages
175
Hi there I've been wondering what would be the best way to extract just like using "=mid()" and "=find()" formulas in vba for extracting information saved within a variable.
An example of what i mean.
A cell contains info such as: "Mr. Robert Kinsley"
I want to save that info within a variable (which i know how) but then using the excel formulas extract everything from the "." to the right (i.e: Robert Kinsley"

Normally I would paste the formula that would make me achieve that in a cell and then retrieve that information but is there a way to manipulate / use those "=mid() , =find(), etc" formulas in vba directly without pasting the actual formula in a cell, so then i could just do this manipulation and save it within a new variable and then paste the exact info I want and not the surplus "title" names etc which I don't want.

Thank you for your help.
finaljustice
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi

Yes. You also have in vba the functions Mid(), Left() and Right() that are very similar to the ones you use in the worksheet.

Check the help on those functions and post back if you have difficulties using them.
 
Upvote 0
Hi

Yes. You also have in vba the functions Mid(), Left() and Right() that are very similar to the ones you use in the worksheet.

Check the help on those functions and post back if you have difficulties using them.


Could you write down an example of how you would do it in vba? That way i can easily replicate and apply to my necessities, since I'm not very familiar with this type of coding since i've never done it before.

Thank you for replying!
 
Upvote 0
It's exactly like the formula you use in excel.
Anyways, if you haven't done any programming before, you might want to start by looking up "VBA Tutorials" on Google or your search engine.

Anyways, just to give you a taste, here is a very simple 'program.'

Code:
'Use " ' " at the front to comment your code and state purpose of code and algorithm of code for future user.
Sub Test()
    MsgBox Left("Hello", 1) 'Get first letter of "Hello"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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