VBA copy right/left/mid of cell contents

teatimecrumpet

Active Member
Joined
Jun 23, 2010
Messages
307
Hi,

I know there is a formula to do this. But is it possible to copy the, say right five charcaters of a string in a cell and then pasting that into another cell/sheet/workbook all in VBA?

Just wondering if avoiding a cell formula to grab content is possible.

thanks,
Mike
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Dim LResult As String
LResult = Right("Alphabet",3)
Range("A10") = LResult

This should work.

This would return "bet" in A10

Change alphabet to your cell (and change Right to whatever function suits your fancy)!
 
Upvote 0
Andrew,

Is there a list of functions that VBA performs? I didn't know it had built-in LEFT,Right,MID capabilities.

Is there a list of functions it recognizes (compared to excel functions)?
 
Upvote 0
Thanks Guys,

Both sets work well.

Desu I've bookmarked that website onto my bar. thanks for that!

I was stuck in the whole "everything should be copy and pasted".

thanks Again
 
Upvote 0
There's an alphabetical list of functions in Help under Microsoft Visual Basic Documentation|Visual Basic Language Reference|Functions. Or you can see them under the VBA <globals> Class in the Object Browser.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,879
Members
452,948
Latest member
Dupuhini

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