Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Left three text characters

I have a variable called "myMonth". I would like this
variable to be set to the first three text characters in
cell "G3".

For instance, if G3 is January, I'd like for myMonth to
equal "Jan"

I know that in Excel, I would have the formula be =left
(D3,3). How do I put this into VB code?

Thanks,
Mike.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Left three text characters

Hi Mike,

It's very similar to the worksheet function:

myMonth = Left$(Sheets("Sheet1").Range("G3").Value, 3)

You may want to use .Text instead of .Value, depending on what is actually
stored in the cell - the Text property returns the text displayed to the
user, while the Value property returns the actual value of the cell.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Mike wrote:
I have a variable called "myMonth". I would like this
variable to be set to the first three text characters in
cell "G3".

For instance, if G3 is January, I'd like for myMonth to
equal "Jan"

I know that in Excel, I would have the formula be =left
(D3,3). How do I put this into VB code?

Thanks,
Mike.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Left three text characters

sVar = Left(Worksheets(1).Cells(3, 4).Value, 3) - Pikus


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Left three text characters

Thanks, Jake!


-----Original Message-----
Hi Mike,

It's very similar to the worksheet function:

myMonth = Left$(Sheets("Sheet1").Range("G3").Value,

3)

You may want to use .Text instead of .Value, depending

on what is actually
stored in the cell - the Text property returns the text

displayed to the
user, while the Value property returns the actual value

of the cell.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


Mike wrote:
I have a variable called "myMonth". I would like this
variable to be set to the first three text characters

in
cell "G3".

For instance, if G3 is January, I'd like for myMonth to
equal "Jan"

I know that in Excel, I would have the formula be =left
(D3,3). How do I put this into VB code?

Thanks,
Mike.


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Left three text characters

You're welcome, Mike - glad to help!

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Mike wrote:
Thanks, Jake!


-----Original Message-----
Hi Mike,

It's very similar to the worksheet function:

myMonth = Left$(Sheets("Sheet1").Range("G3").Value, 3)

You may want to use .Text instead of .Value, depending on what is
actually stored in the cell - the Text property returns the text
displayed to the user, while the Value property returns the actual
value of the cell.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Mike wrote:
I have a variable called "myMonth". I would like this
variable to be set to the first three text characters in
cell "G3".

For instance, if G3 is January, I'd like for myMonth to
equal "Jan"

I know that in Excel, I would have the formula be =left
(D3,3). How do I put this into VB code?

Thanks,
Mike.


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Left three text characters

Since Cells(3,4) refers to D3 rather than G3 as requested, and otherwise,
your post pretty much duplicates what Mr. Marx said, what was the added
value of your post? I don't want to miss the important message you intended
to convey.

--
Regards,
Tom Ogilvy



"pikus" wrote in message
...
sVar = Left(Worksheets(1).Cells(3, 4).Value, 3) - Pikus


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get characters on left of specified character in Excel Murugan Excel Discussion (Misc queries) 3 April 2nd 23 04:15 PM
testing for left 2 characters in set of 3 choices MusicMan Excel Worksheet Functions 5 January 19th 10 11:30 PM
Find duplicates with left 4 characters brumanchu Excel Discussion (Misc queries) 3 September 15th 09 03:11 PM
Excel 2003, SUM left-most characters David Aukerman Excel Worksheet Functions 13 January 15th 09 03:35 AM
HOW DO I EXTRACT ALL CHARACTERS AFTER 5 CHARACTERS ON LEFT GRYSYF Excel Worksheet Functions 5 October 12th 05 10:58 AM


All times are GMT +1. The time now is 02:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"