Return a charactar from a cell value

M

Marcus Ostman

Simple question!
How do I return a scharactar from a cell value in VB?

Like...
ANSWER = Left(Activecell.Value, 10)
Msgbox ANSWER
....but for example I just want to return one charactar, the ninth,
from the cell value.

regards
Marcus
 
E

Earl Kiosterud

Marcus,

MsgBox Left(ActiveCell, 10)

or:

Dim MyString as String
MyString = ActiveCell.Value
MsgBox MyString
 
D

David McRitchie

Hi Marcus,

Somewhat ambiguous because cell.value is not a position.
To Return a single character, use one of the following:

If you want the leftmost character
variable = LEFT(cell.value,1)

If you want the last character
variable =RIGHT(cell.value,1)

If you want the 10th character
variable = MID(cell.value,10,1)

Please look each of these up in the VBE Help.
You must be in the VBE when invoking Help (F1).
If you switch to Excel, reinvoke help to see Excel Help.
 
Top